[package]
name = "syslog-rs"
version = "6.5.1"
authors = ["Aleksandr Morozov <alex@nixd.org>"]
edition = "2024"
description="A native Rust implementation of the glibc/libc/windows syslog client and windows native log for logging."
repository = "https://codeberg.org/4neko/syslog-rs"
keywords = ["syslog", "logging", "logs", "rsyslog", "eventlog"]
categories = ["asynchronous", "os"]
license="MIT OR MPL-2.0 OR EUPL-1.2"

[profile.dev]
opt-level = 0


[features]

# Deafult features.
default = ["build_sync", "truncate_default"]

# A default net message truncation.
truncate_default = ["udp_truncate_1440_bytes", "tcp_truncate_2048_bytes"]

# A base feature which enables all SYNC code. Just enabling the `use_sync`
# would enable only basic SharedSyslog.
build_sync = ["dep:crossbeam-utils"]

# Include the single threaded instance without locks.
build_with_thread_local = ["build_sync"]

# -- OPTIONAL ASYNC PROVIDERS ---
# ! Only one can be included at a time.

# A Tokio based async IO. Includes the tokio and tokio-rustls deps.
build_async_tokio = ["async_embedded", "dep:tokio", "dep:tokio-rustls"]
# - OR -
# A Smol based async IO. Includes the smol and futures-rustls deps.
build_async_smol = ["async_embedded", "dep:smol", "dep:futures-rustls"]
# - OR -
# An experimental thing. It allows to implement the async functionality for some
# exotic or own async executors without implementing it into the crate's base.
# See /docs/async_interface.md
build_async_interface = ["async_enabled"]

# Adds the queues. This feature enables the additional realization which 
# moves the syslog client to separate thread and by default uses 
# crossbeam-channel to receive messages.
# Depending on which async procvider is selected, the channel realization 
# will be switched suring compilation. In this case, an async code can be 
# attached to the sync queue which allows to write to the same syslog
# connection with the same setup.
build_with_queue = ["build_sync", "dep:crossbeam-channel"]


# Adds the networking support! (TCP, UDP)
build_ext_net = []

# Adds the TLS support over network (TCP).
build_ext_tls = ["build_ext_net", "dep:rustls"]

# Adds the local writer which writes directly to file. Useful when
# the syslog is not yet available but filesystem is already attached and
# syslog messages can be tapped to local file.
build_ext_file = []

# -! RFC5424 ONLY !- 

# UDP
# A features which modifiers the behaviour of UDP message length.

## Forces truncation of the (whole) syslog message to 1024
udp_truncate_1024_bytes = []

## Forces truncation of the (whole) syslog message to 1440
udp_truncate_1440_bytes = []

# TCP
## Forces truncation of the (whole) syslog message to 1024 
tcp_truncate_1024_bytes = []

## Forces truncation of the (whole) syslog message to 2048 
tcp_truncate_2048_bytes = []

## Forces truncation of the (whole) syslog message to 4096 
tcp_truncate_4096_bytes = []

## Forces truncation of the (whole) syslog message to 8192 (max)
tcp_truncate_max_bytes = []


# UNIX DATAGRAM

## *BSD only!
## By default, if crate fails to obtain a sysctl net.local.dgram.maxdgram, it returns
## a default value 2048. If this feature is enabled, then it will panic.
dgram_sysctl_failure_panic = []

# ---

# -! PRIVATE FEATURES !-
# Do NOT use directly.

# Tells that the base async is enabled.
async_enabled = []

# Tells that the embedded async exec environment is used.
async_embedded = ["async_enabled"]

example_tokio_en = ["dep:tokio"]
# -!!PRIVATE FEATURES!!-

[package.metadata.docs.rs]
features = ["build_sync", "truncate_default", "build_with_thread_local", "build_async_tokio", "build_with_queue", "build_ext_net", "build_ext_tls", "build_ext_file"]
no-default-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
bitflags = "~2"
chrono = "~0.4"

crossbeam-channel = { version = "~0.5", optional = true }
crossbeam-utils = { version = "~0.8", optional = true }

tokio = { version = "~1", optional = true, features = ["rt-multi-thread", "net", "macros", "time", "sync", "io-util", "io-std", "fs"] } 
smol = { version = "~2.0", optional = true }

socket2 = "~0.6"
rustls = { version = "~0.23", optional = true }
tokio-rustls = { version = "~0.26", optional = true }
futures-rustls = { version = "~0.26", optional = true }

instance-copy-on-write = { version = "~0.7" } # MIT

[target.'cfg(unix)'.dependencies]
nix = { version = "~0.30", features = ["hostname"] }

[target.'cfg(windows)'.dependencies]
windows = { version = "~0.62", features = ["Win32_System_EventLog", "Win32_Security", "Win32_System_Diagnostics_Etw", "Win32_System_SystemInformation", "Win32_Networking_WinSock"] }


[dev-dependencies]
tokio-test = "0.4"


[[example]]
name = "example_async"
required-features = ["build_async_tokio"]

[[example]]
name = "example_udp"
required-features = ["build_ext_net"]

[[example]]
name = "example_sync"
required-features = ["build_sync"]

[[example]]
name = "example_formatter"
required-features = ["build_sync"]

[[example]]
name = "example_sync_stream"
required-features = ["build_sync"]

[[example]]
name = "example_sync_queue"
required-features = ["build_with_queue"]

# testing the logging into file when syslog is not available or not required from both sync and async
[[example]]
name = "example_logtofile"
required-features = ["build_async_tokio", "build_ext_file", "build_with_queue"]

[[example]]
name = "example_tls"
required-features = ["build_ext_tls"]

[[example]]
name = "example_logto_file_sync"
required-features = ["build_ext_file"]

[[example]]
name = "example_logto_file_async"
required-features = ["build_async_tokio", "build_ext_file"]

[[example]]
name = "example_custom_formatter"
required-features = ["build_ext_file"]

[[example]]
name = "example_smol_async"
required-features = ["build_async_smol"]

[[example]]
name = "example_inteface"
required-features = ["build_async_interface", "example_tokio_en"]

[[example]]
name = "example_thread_local"
required-features = ["build_with_thread_local"]

[[example]]
name = "example_sync_heavy_load"
required-features = ["build_sync"]
