Crates.io | fasyslog |
lib.rs | fasyslog |
version | 1.0.1 |
created_at | 2024-11-11 19:06:46.05811+00 |
updated_at | 2025-05-07 15:10:13.198303+00 |
description | A fast syslog client written in Rust. |
homepage | |
repository | https://github.com/fast/fasyslog |
max_upload_size | |
id | 1444103 |
size | 118,435 |
Client library written in Rust to send messages to a Syslog server. Support implementations:
UdpSender
: RFC 5426 - Transmission of Syslog Messages over UDPTcpSender
: RFC 6587 - Transmission of Syslog Messages over TCPNativeTlsSender
: RFC 5425 - Transport Layer Security (TLS) Transport Mapping for Syslog
native-tls
and requires features native-tls
turned on.RustlsSender
: RFC 5425 - Transport Layer Security (TLS) Transport Mapping for Syslog
rustls
and requires features rustls
turned on.Add fasyslog
to your Cargo.toml
:
cargo add fasyslog
use fasyslog::Severity;
fn main() {
let mut sender = fasyslog::sender::tcp_well_known().unwrap();
let message = format!("Hello, fasyslog!");
// send a message with RFC 3164 format
sender.send_rfc3164(Severity::ERROR, message).unwrap();
sender.flush().unwrap();
// send a message with RFC 5424 format
const EMPTY_MSGID: Option<&str> = None;
const EMPTY_STRUCTURED_DATA: Vec<fasyslog::SDElement> = Vec::new();
sender.send_rfc5424(Severity::ERROR, EMPTY_MSGID, EMPTY_STRUCTURED_DATA, message).unwrap();
sender.flush().unwrap();
}
If you'd like to integrate with log
crate, you can try the logforth
example:
[dependencies]
log = { version = "..." }
logforth = { version = "...", features = ["syslog"] }
use logforth::append::syslog::SyslogBuilder;
fn main() {
let (append, _guard) = SyslogBuilder::tcp_well_known().unwrap().build();
logforth::builder()
.dispatch(|d| d.filter(log::LevelFilter::Trace).append(append))
.apply();
log::info!("This log will be written to syslog.");
}
Check the examples directory for more examples.
Read the online documents at https://docs.rs/fasyslog.
This crate is built against the latest stable release, and its minimum supported rustc version is 1.75.0.
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Fasyslog 1.0 requires Rust 1.20.0, then Fasyslog 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Fasyslog 1.y for y > 0 may require a newer minimum version of Rust.
This project is licensed under Apache License, Version 2.0.