-
Couldn't load subscription status.
- Fork 21
Open
Description
The add_default_keys() method sets the level field to use the short version version of log fields (e.g. ERRO for Error). If a user does not want to use the short field names, they must essentially re-implement add_default_keys() themselves.
That is,
let drain = slog_json::Json::default(std::io::stderr())now becomes
let drain = slog_json::Json::new(std::io::stderr())
.add_key_value(slog::o!(
"ts" => slog::FnValue(move |_: &slog::Record| {
time::OffsetDateTime::now_utc()
.format(&time::format_description::well_known::Rfc3339)
.ok()
}),
"level" => slog::FnValue(move |rinfo: &slog::Record| {
rinfo.level().as_str()
}),
"msg" => slog::PushFnValue(move |record: &slog::Record, ser| {
ser.emit(record.msg())
}),
))
.build();which also requires adding a (top level) dependency on the time crate.
I would like to be able to use the default keys, but be able to choose the strings used for the log levels. Example API:
let drain = slot_json::Json::new(std::io::stderr())
.add_default_keys()
.with_log_levels(["off", "critical", "error", "warn", "info", "debug", "trace"])
.build();Metadata
Metadata
Assignees
Labels
No labels