Expand description
This crate provides an API implementing the standard Rust logging facade to the system’s syslog. That is, it implements the Log trait of the log crate for native syslog (the one typically implemented in C and residing in libc).
Syslog needs to be initialized prior to any logging macros being called. That is usally done through a single chained call of its builder, with optional methods to customize the logger before finalizing the setup by calling build and init.
Typical use: (A.k.a. recommended snippet to copy’n’paste to the start of
main()
of your daemon.)
libsyslog::Syslog::builder()
.module_level(std::module_path!(), log::LevelFilter::Info)
.level(log::LevelFilter::Off)
.build()
.init()?;
error!("Hello libsyslog. I've failed you.");
It is likely reasonable for most users to configure the module_level and level filters to only have the application’s own log messages sent to syslog (ignoring potentially chatty libraries), as in the above example.
The scope of this crate is limited as described by the very first paragraph
above. Its intended use is during normal operation, in software with modest
requirements on low frequency logging. Note that syslog risks killing
performance. Consider using another additional facade, in combination with
a --no-daemon
option, for when developing and debugging. And please
remember, if libsyslog does not meet your requirements, there
are plenty of other crates for logging around.
Structs
- Typesafe representation of syslog logopt bitflags.
- Logger object to make log output message to syslog.
- Builder used to create and customize the Syslog logger object.
Enums
- Typesafe representation of syslog facility constants.