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

--debug-level flag not working #638

Closed
paulhauner opened this issue Nov 27, 2019 · 1 comment · Fixed by #721
Closed

--debug-level flag not working #638

paulhauner opened this issue Nov 27, 2019 · 1 comment · Fixed by #721
Labels
bug Something isn't working

Comments

@paulhauner
Copy link
Member

Description

I suspect that the lighthosue --debug-level flag is not working.

The flag is defined here:

.arg(
Arg::with_name("debug-level")
.long("debug-level")
.value_name("LEVEL")
.help("The title of the spec constants for chain config.")
.takes_value(true)
.possible_values(&["info", "debug", "trace", "warn", "error", "crit"])
.default_value("trace"),
)

The code that applies the level is here:

/// Specifies that the `slog` asynchronous logger should be used. Ideal for production.
///
/// The logger is "async" because it has a dedicated thread that accepts logs and then
/// asynchronously flushes them to stdout/files/etc. This means the thread that raised the log
/// does not have to wait for the logs to be flushed.
pub fn async_logger(mut self, debug_level: &str) -> Result<Self, String> {
// Build the initial logger.
let decorator = slog_term::TermDecorator::new().build();
let decorator = logging::AlignedTermDecorator::new(decorator, logging::MAX_MESSAGE_WIDTH);
let drain = slog_term::FullFormat::new(decorator).build().fuse();
let drain = slog_async::Async::new(drain).build();
let drain = match debug_level {
"info" => drain.filter_level(Level::Info),
"debug" => drain.filter_level(Level::Debug),
"trace" => drain.filter_level(Level::Trace),
"warn" => drain.filter_level(Level::Warning),
"error" => drain.filter_level(Level::Error),
"crit" => drain.filter_level(Level::Critical),
unknown => return Err(format!("Unknown debug-level: {}", unknown)),
};
self.log = Some(Logger::root(drain.fuse(), o!()));
Ok(self)
}
/// Consumes the builder, returning an `Environment`.
pub fn build(self) -> Result<Environment<E>, String> {
Ok(Environment {
runtime: self
.runtime
.ok_or_else(|| "Cannot build environment without runtime".to_string())?,
log: self
.log
.ok_or_else(|| "Cannot build environment without log".to_string())?,
eth_spec_instance: self.eth_spec_instance,
eth2_config: self.eth2_config,
})
}
}

Steps to fix

  1. Confirm my suspicion.
  2. Fix it.
  3. Prove to yourself that the level is effective.
@paulhauner paulhauner added the bug Something isn't working label Nov 27, 2019
@paulhauner
Copy link
Member Author

So it turns out the flag is working when outputting to the CLI but not when outputting to file (using --log-file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant