Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reexport broadcast and native_tls from fasyslog #81

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rustdoc-args = ["--cfg", "docsrs"]
fastrace = ["dep:fastrace"]
journald = ["dep:libc"]
json = ["dep:serde_json", "dep:serde", "jiff/serde"]
native-tls = ["dep:native-tls", "fasyslog?/native-tls"]
no-color = ["colored/no-color"]
non-blocking = ["dep:crossbeam-channel"]
opentelemetry = [
Expand All @@ -55,8 +56,9 @@ log = { version = "0.4", features = ["std", "kv_unstable"] }
# Optional dependencies
crossbeam-channel = { version = "0.5", optional = true }
fastrace = { version = "0.7", optional = true }
fasyslog = { version = "0.2", optional = true }
fasyslog = { version = "0.3", optional = true }
libc = { version = "0.2.162", optional = true }
native-tls = { version = "0.2", optional = true }
opentelemetry = { version = "0.27", features = ["logs"], optional = true }
opentelemetry-otlp = { version = "0.27", features = [
"logs",
Expand Down
45 changes: 45 additions & 0 deletions src/append/syslog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,51 @@ impl SyslogWriter {
.map(Self::new)
}

/// Create a new syslog writer that broadcast messages to the well-known UDP port (514).
pub fn broadcast_well_known() -> io::Result<SyslogWriter> {
fasyslog::sender::broadcast_well_known()
.map(SyslogSender::Udp)
.map(Self::new)
}

/// Create a new syslog writer that broadcast messages to the given UDP address.
pub fn broadcast(port: u16) -> io::Result<SyslogWriter> {
fasyslog::sender::broadcast(port)
.map(SyslogSender::Udp)
.map(Self::new)
}

/// Create a TLS sender that sends messages to the well-known port (6514).
#[cfg(feature = "native-tls")]
pub fn native_tls_well_known<S: AsRef<str>>(domain: S) -> io::Result<SyslogWriter> {
fasyslog::sender::native_tls_well_known(domain)
.map(SyslogSender::NativeTlsSender)
.map(Self::new)
}

/// Create a TLS sender that sends messages to the given address.
#[cfg(feature = "native-tls")]
pub fn native_tls<A: std::net::ToSocketAddrs, S: AsRef<str>>(
addr: A,
domain: S,
) -> io::Result<SyslogWriter> {
fasyslog::sender::native_tls(addr, domain)
.map(SyslogSender::NativeTlsSender)
.map(Self::new)
}

/// Create a TLS sender that sends messages to the given address with certificate builder.
#[cfg(feature = "native-tls")]
pub fn native_tls_with<A: std::net::ToSocketAddrs, S: AsRef<str>>(
addr: A,
domain: S,
builder: native_tls::TlsConnectorBuilder,
) -> io::Result<SyslogWriter> {
fasyslog::sender::native_tls_with(addr, domain, builder)
.map(SyslogSender::NativeTlsSender)
.map(Self::new)
}

/// Create a new syslog writer that sends messages to the given Unix stream socket.
#[cfg(unix)]
pub fn unix_stream(path: impl AsRef<std::path::Path>) -> io::Result<SyslogWriter> {
Expand Down