Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use GRAPH_LOG to set log level for graphman #4462

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion graph/src/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub mod factory;
pub mod split;

pub fn logger(show_debug: bool) -> Logger {
logger_with_levels(show_debug, ENV_VARS.log_levels.as_deref())
}

pub fn logger_with_levels(show_debug: bool, levels: Option<&str>) -> Logger {
let use_color = isatty::stdout_isatty();
let decorator = slog_term::TermDecorator::new().build();
let drain = CustomFormat::new(decorator, use_color).fuse();
Expand All @@ -44,7 +48,7 @@ pub fn logger(show_debug: bool) -> Logger {
FilterLevel::Info
},
)
.parse(ENV_VARS.log_levels.as_deref().unwrap_or(""))
.parse(levels.unwrap_or(""))
.build();
let drain = slog_async::Async::new(drain)
.chan_size(20000)
Expand Down
16 changes: 10 additions & 6 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use clap::{Parser, Subcommand};
use config::PoolSize;
use git_testament::{git_testament, render_testament};
use graph::bail;
use graph::log::logger_with_levels;
use graph::prelude::{MetricsRegistry, BLOCK_NUMBER_MAX};
use graph::{data::graphql::effort::LoadManager, prelude::chrono, prometheus::Registry};
use graph::{
log::logger,
prelude::{
anyhow::{self, Context as AnyhowContextTrait},
info, o, slog, tokio, Logger, NodeId, ENV_VARS,
info, tokio, Logger, NodeId,
},
url::Url,
};
Expand Down Expand Up @@ -47,6 +47,13 @@ lazy_static! {
version = RENDERED_TESTAMENT.as_str()
)]
pub struct Opt {
#[clap(
long,
default_value = "off",
env = "GRAPHMAN_LOG",
help = "level for log output in slog format"
)]
pub log_level: String,
#[clap(
long,
default_value = "auto",
Expand Down Expand Up @@ -910,10 +917,7 @@ async fn main() -> anyhow::Result<()> {

let version_label = opt.version_label.clone();
// Set up logger
let logger = match ENV_VARS.log_levels {
Some(_) => logger(false),
None => Logger::root(slog::Discard, o!()),
};
let logger = logger_with_levels(false, Some(&opt.log_level));

// Log version information
info!(
Expand Down