All notable changes to this project will be documented in this file.
- Migrate from
log
'skv_unstable
feature tokv
feature (#85).
module_path
is replaced bytarget
inJsonLayout
andTextLayout
(#82).- Error perform logging now prints error in Debug format (#84)
- Re-export
broadcast
andnative_tls
constructors from fasyslog (#81).
- The mapping between syslog severity and log's level is changed.
log::Level::Error
is mapped tosyslog::Severity::Error
(unchanged).log::Level::Warn
is mapped tosyslog::Severity::Warning
(unchanged).log::Level::Info
is mapped tosyslog::Severity::Notice
(changed).log::Level::Debug
is mapped tosyslog::Severity::Info
(changed).log::Level::Trace
is mapped tosyslog::Severity::Debug
(unchanged).
- Add
journald
feature to support journald appenders (#80).
- Change the re-export of
syslog
tologforth::syslog::fasyslog
(#74)
- Add
syslog
feature to support syslog appenders (#72)
Two breaking changes in #72:
rolling_file
feature flag is renamed torolling-file
.NonBlocking
related structures and methods are relocated, now you'd construct a non-blocking like:
fn main() {
let rolling_writer = RollingFileWriter::builder()
.rotation(Rotation::Daily)
.filename_prefix("app_log")
.build("logs")
.unwrap();
let (non_blocking, _guard) = rolling_file::non_blocking(rolling_writer).finish();
logforth::builder()
.dispatch(|d| {
d.filter(log::LevelFilter::Trace)
.append(RollingFile::new(non_blocking).with_layout(JsonLayout::default()))
})
.apply();
}
or:
fn main() {
let syslog_writer = SyslogWriter::tcp_well_known().unwrap();
let (non_blocking, _guard) = syslog::non_blocking(syslog_writer).finish();
logforth::builder()
.dispatch(|d| {
d.filter(log::LevelFilter::Trace)
.append(Syslog::new(non_blocking))
})
.apply();
}
Note that each NonBlocking
now has a type parameter to ensure that they match the corresponding appenders.
Two minor breaking changes in #71:
JsonLayout
's fieldtz
is now private. You can change it with the newtimezone
method, likeJsonLayout::default().timezone(TimeZone::UTC)
.DispatchBuilder
now always acceptsfilter
first, and thenappend
. Once anappend
is configured, no morefilter
can be added. This is for a strict order on config so that the code is more consistent.
API is further improve in both #69 and #70.
Now the logger build logic is like:
use log::LevelFilter;
use logforth::append;
use logforth::layout::JsonLayout;
fn main() {
logforth::builder()
.dispatch(|b| b.filter(LevelFilter::Debug).append(append::Stderr::default().with_layout(JsonLayout::default())))
.dispatch(|b| b.filter(LevelFilter::Info).append(append::Stdout::default().with_layout(JsonLayout::default())))
.apply();
}
And we provide a convenient way to build the logger with default setup (stderr or stdout, with RUST_LOG envvar respected):
fn main() {
logforth::stderr().apply();
// or logforth::stdout().apply(); // for logging to stdout
}
-
refactor: layouts and encoders should be nested to appenders (#64)
Previous code:
fn main() { Logger::new() .dispatch( Dispatch::new() .filter(LevelFilter::Trace) .layout(JsonLayout::default()) .append(append::Stdout), ) .apply() .unwrap(); log::error!("Hello error!"); log::warn!("Hello warn!"); log::info!("Hello info!"); log::debug!("Hello debug!"); log::trace!("Hello trace!"); }
New code:
fn main() { Logger::new() .dispatch( Dispatch::new() .filter(LevelFilter::Trace) .append(append::Stdout::default().with_layout(JsonLayout::default())), ) .apply() .unwrap(); log::error!("Hello error!"); log::warn!("Hello warn!"); log::info!("Hello info!"); log::debug!("Hello debug!"); log::trace!("Hello trace!"); }
Besides, the default layout of Stdout, Stderr, and RollingFile is changed from
IdenticalLayout
toTextLayout
. -
refactor: unify level/target filter to directive filter (#65)
Most
From
conversions are kept so that typically you won't notice the change. But if you directly useLevelFilter
andTargetFilter
, they are now removed. The functionalities can be covered byEnvFilter
.Also, the feature flag
env-filter
is removed. TheEnvFilter
is always available now.