Skip to content

Commit

Permalink
Add a message to the logs indicating that RUST_LOG or APOLLO_ROUTER_L…
Browse files Browse the repository at this point in the history
…OG must be configured to log entries from custom plugins.

Fixes #3526
  • Loading branch information
bryn committed Aug 4, 2023
1 parent 19ea4d9 commit fad1656
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use url::Url;
use crate::configuration::generate_config_schema;
use crate::configuration::generate_upgrade;
use crate::configuration::Discussed;
use crate::plugin::plugins;
use crate::plugins::telemetry::reload::init_telemetry;
use crate::router::ConfigurationSource;
use crate::router::RouterHttpServer;
Expand Down Expand Up @@ -615,6 +616,17 @@ impl Executable {
}
};

// If there are custom plugins then if RUST_LOG hasn't been set and APOLLO_ROUTER_LOG contains one of the defaults.
let user_plugins_present = plugins().filter(|p| !p.is_apollo()).count() > 0;
let rust_log_set = std::env::var("RUST_LOG").is_ok();
let apollo_router_log = std::env::var("APOLLO_ROUTER_LOG").unwrap_or_default();
if user_plugins_present
&& !rust_log_set
&& ["", "off", "trace", "debug", "warn", "info"].contains(&apollo_router_log.as_str())
{
tracing::info!("Custom plugins are present. To see log messages from your plugins you must configure `RUST_LOG` or `APOLLO_ROUTER_LOG` environment variables. See the Router logging documentation for more details");
}

let router = RouterHttpServer::builder()
.configuration(configuration)
.and_uplink(opt.uplink_config().ok())
Expand Down
3 changes: 3 additions & 0 deletions apollo-router/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ impl fmt::Debug for PluginFactory {
}

impl PluginFactory {
pub(crate) fn is_apollo(&self) -> bool {
self.name.starts_with("apollo.") || self.name.starts_with("experimental.")
}
/// Create a plugin factory.
pub fn new<P: Plugin>(group: &str, name: &str) -> PluginFactory {
let plugin_factory_name = if group.is_empty() {
Expand Down

0 comments on commit fad1656

Please sign in to comment.