-
Notifications
You must be signed in to change notification settings - Fork 95
Yes. See slog-stdlog crate and slog oldlogging example.
#[macro_use]
extern crate log;
extern crate slog_stdlog;
fn main() {
slog_stdlog::init().unwrap();
// Note: this `info!(...)` macro comes from `log` crate, but it will
// delivered to slog handling
// See https://docs.rs/slog-stdlog/1.1.0/slog_stdlog/fn.set_logger.html
info!("standard logging redirected to slog");
}
or if you were using env_logger
before:
#[macro_use]
extern crate log;
extern crate slog_envlogger;
fn main() {
slog_envlogger::init().unwrap();
// Note: this `info!(...)` macro comes from `log` crate
info!("standard logging redirected to slog");
}
If you start a new project, you should just use slog
and not log
.
If you're just trying out slog
in existing project, you can use slog-stdlog and keep using log
crate macros. During transition period to slog
, you can use alternative names of slog
macros. See slog
alternative names example
Yes. Every closure-value is provided with RecordInfo
argument which contains that information. Output it under any name you want, any way you want. See slog file-line-module example.
Yes. slog-rs
provides the same Cargo.toml
-defined feature
-s that standard log
did, that allow completely disabling given logging levels at compile time. One difference is, by default slog
disables lowest logging levels.
Not really. You can help yourself using slog-scope
.