Expand description
Facilities for sending log message to syslog.
Every function exported by this module is thread-safe. Each function will silently fail until
syslog::init() is called and returns Ok.
This implements and sets logger up for logging facade exposed by the log
crate.
§Examples
use log::{error, warn};
use base::syslog;
if let Err(e) = syslog::init() {
println!("failed to initiailize syslog: {}", e);
return;
}
warn!("this is your {} warning", "final");
error!("something went horribly wrong: {}", "out of RAMs");use log::{error, warn};
use base::syslog::{init_with, LogConfig, fmt};
use std::io::Write;
let mut cfg = LogConfig::default();
cfg.log_args.stderr = true;
cfg.log_args.filter = String::from("info,base=debug,base::syslog=error,serial_console=false");
init_with(cfg).unwrap();
error!("something went horribly wrong: {}", "out of RAMs");Re-exports§
pub use env_logger;
Modules§
- fmt
- Formatting for log records.
Macros§
- debug
- Logs a message at the debug level.
- error
- Logs a message at the error level.
- info
- Logs a message at the info level.
- log
- The standard logging macro.
- log_
enabled - Determines if a message logged at the specified level in that module will be logged.
- trace
- Logs a message at the trace level.
- warn
- Logs a message at the warn level.
Structs§
- LogArgs
- LogConfig
- Logging
Facade 🔒 - The logger that is provided to the
logcrate. Wraps our State struct so that we can reconfigure logging sinks on the fly. - Metadata
- Metadata about a log message.
- Metadata
Builder - Builder for
Metadata. - Parse
Level Error - The type returned by
from_strwhen the string doesn’t match any of the log levels. - Record
- The “payload” of a log message.
- Record
Builder - Builder for
Record. - SetLogger
Error - The type returned by
set_loggerifset_loggerhas already been called. - State
- Syslogger
Enums§
- Error
- Errors returned by
syslog::init(). - Facility
- The facility of a syslog message.
- Level
- An enum representing the available verbosity levels of the logger.
- Level
Filter - An enum representing the available verbosity level filters of the logger.
- Priority
- The priority (i.e. severity) of a syslog message.
Constants§
- STATIC_
MAX_ LEVEL - The statically resolved maximum log level.
Statics§
Traits§
Functions§
- apply_
logging_ 🔒state - early_
init - Performs early (as in, moment of process start) logging initialization. Any logging prior to this call will be SILENTLY discarded. Calling more than once per process will panic.
- init
- Initialize the syslog connection and internal variables.
- init_
with - Initialize the syslog connection and internal variables.
- logger
- Returns a reference to the logger.
- max_
level - Returns the current maximum log level.
- push_
descriptors - Retrieves the file descriptors owned by the global syslogger.
- set_
boxed_ logger - Sets the global logger to a
Box<Log>. - set_
logger - Sets the global logger to a
&'static Log. - set_
logger_ ⚠racy - A thread-unsafe version of
set_logger. - set_
max_ level - Sets the global maximum log level.
- set_
max_ ⚠level_ racy - A thread-unsafe version of
set_max_level. - test_
only_ ensure_ inited - Test only function that ensures logging has been configured. Since tests share module state, we need a way to make sure it has been initialized with some configuration.