Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

Cratesyslog

Source
Expand description

Syslog

This crate provides facilities to send log messages via syslog.It supports Unix sockets for local syslog, UDP and TCP for remote servers.

Messages can be passed directly without modification, or in RFC 3164 or RFC 5424 format

The code is available onGithub

§Example

usesyslog::{Facility, Formatter3164};letformatter = Formatter3164 {    facility: Facility::LOG_USER,    hostname:None,    process:"myprogram".into(),    pid:0,};matchsyslog::unix(formatter) {Err(e) =>println!("impossible to connect to syslog: {:?}", e),Ok(mutwriter) => {        writer.err("hello world").expect("could not write error message");    }}

It can be used directly with the log crate as follows:

extern cratelog;usesyslog::{Facility, Formatter3164, BasicLogger};uselog::{SetLoggerError, LevelFilter, info};letformatter = Formatter3164 {    facility: Facility::LOG_USER,    hostname:None,    process:"myprogram".into(),    pid:0,};letlogger =matchsyslog::unix(formatter) {Err(e) => {println!("impossible to connect to syslog: {:?}", e);return; },Ok(logger) => logger,};log::set_boxed_logger(Box::new(BasicLogger::new(logger)))        .map(|()| log::set_max_level(LevelFilter::Info));info!("hello world");

Structs§

BasicLogger
Formatter3164
Formatter5424
Logger
Main logging structure

Enums§

Error
Facility
LoggerBackend
Severity

Traits§

LogFormat

Functions§

init
Initializes logging subsystem for log crate
init_tcp
TCP Logger init function compatible with log crate
init_udp
UDP Logger init function compatible with log crate
init_unix
Unix socket Logger init function compatible with log crate
init_unix_custom
Unix socket Logger init function compatible with log crate and user provided socket path
tcp
returns a TCP logger connectinglocal andserver
udp
returns a UDP logger connectinglocal andserver
unix
Returns a Logger using unix socket to target local syslog ( using /dev/log or /var/run/syslog)
unix_custom
Returns a Logger using unix socket to target local syslog at user provided path

Type Aliases§

Priority
Result

[8]ページ先頭

©2009-2025 Movatter.jp