Crate slog_try[−][src]
Convenience macros for logging with optional slog Logger
s.
Example
#[derive(Default)] struct HasOptLogger { logger: Option<Logger>, } let mut opt_logger: HasOptLogger = Default::default(); try_info!(opt_logger.logger, "You won't see me output. The logger is None."; "opt" => "None"); try_info!(opt_logger.logger, #"imatag", "You won't see me output. The logger is None."; "opt" => "None"); // Setup a `Logger` let plain = slog_term::PlainSyncDecorator::new(::std::io::stdout()); let logger = Logger::root(slog_term::FullFormat::new(plain).build().fuse(), o!("surname" => "Lava")); opt_logger.logger = Some(logger); try_info!(opt_logger.logger, "You will see me output!"; "opt" => "Some"); try_info!(opt_logger.logger, #"imatag", "You will see me output!"; "opt" => "Some");
Macros
try_crit |
Log a crit level message if the given logger is |
try_debug |
Log a debug level message if the given logger is |
try_error |
Log an error level message if the given logger is |
try_info |
Log an info level message if the given logger is |
try_trace |
Log a trace level message if the given logger is |
try_warn |
Log a warn level message if the given logger is |