Crate systemd_journal_logger[−][src]
Expand description
A log logger for the systemd journal.
Usage
Use init
at the beginning of your main
function to setup journal
logging, configure the logging level and then use the standard macros
from the log
crate to send log messages to the systemd journal:
ⓘ
use log::{info, warn, error, LevelFilter}; systemd_journal_logger::init().unwrap(); log::set_max_level(LevelFilter::Info); info!("hello log"); warn!("warning"); error!("oops");
Journal fields
The journald logger always sets the following standard journal fields
PRIORITY
: The log level mapped to a priority (see below).MESSAGE
: The formatted log message (seelog::Record::args()
).SYSLOG_IDENTIFIER
: The short name of the running process, i.e. the file name ofstd::env::current_exe()
if successful.SYSLOG_PID
: The PID of the running process (seestd::process::id()
).CODE_FILE
: The filename the log message originates from (seelog::Record::file()
, only if present).CODE_LINE
: The line number the log message originates from (seelog::Record::line()
, only if present).
Additionally it also adds the following non-standard fields:
TARGET
: The target of the log record (seelog::Record::target()
).RUST_MODULE_PATH
: The module path of the log record (seelog::Record::module_path()
, only if present).
Log levels and priorities
The journal logger maps log::Level
to journal priorities as follows:
Structs
JournalLog | A systemd journal logger. |
Statics
LOG | The static instance of systemd journal logger. |
Functions
init | Initialize journal logging. |