pub struct Log;Expand description
Logging helpers for access logs and server info.
Log::combined produces standard Combined Log Format lines compatible with
GoAccess, AWStats, and similar tools. All three server code paths (HTTP/1.1,
HTTP/2, HTTP/3) use it.
Implementations§
Source§impl Log
impl Log
pub fn request_response( request: &Request, response: &Response, peer_addr: &SocketAddr, ) -> String
pub fn usage_information() -> String
Sourcepub fn current_user() -> String
pub fn current_user() -> String
The user rws runs as, for the startup banner: $USER, $LOGNAME or
%USERNAME%, else "unknown". Deliberately not whoami (what
FileExt::get_current_user runs): minimal container images such as
distroless have no whoami, and the banner’s unwrap() on that
error crashed the published Docker image at startup.
pub fn info(name: &str) -> String
Sourcepub fn json(
request: &Request,
response: &Response,
peer_addr: &SocketAddr,
) -> String
pub fn json( request: &Request, response: &Response, peer_addr: &SocketAddr, ) -> String
Returns a structured JSON log line for one request/response pair.
Enable with RWS_CONFIG_LOG_FORMAT=json. Useful for log aggregators
(Loki, Fluentd, Datadog) that ingest JSON from pod stdout.
Sourcepub fn log_access(
request: &Request,
response: &Response,
peer_addr: &SocketAddr,
)
pub fn log_access( request: &Request, response: &Response, peer_addr: &SocketAddr, )
Writes one access log line to stdout using the format configured by
RWS_CONFIG_LOG_FORMAT ("combined" or "json"). Call this instead of
Log::combined so that format selection is centralised.
Sourcepub fn access_log_line(
request: &Request,
response: &Response,
peer_addr: &SocketAddr,
) -> Option<String>
pub fn access_log_line( request: &Request, response: &Response, peer_addr: &SocketAddr, ) -> Option<String>
The access-log line for RWS_CONFIG_LOG_FORMAT: json (the rws
binary’s default), Combined Log Format for any other value (including
unset, in library use), or None for off/none — no per-request
line, e.g. behind a proxy that already logs or when benchmarking.
Taken from ServerConfig::current(), so it’s hot-reloadable.
Sourcepub fn combined(
request: &Request,
response: &Response,
peer_addr: &SocketAddr,
) -> String
pub fn combined( request: &Request, response: &Response, peer_addr: &SocketAddr, ) -> String
Returns a Combined Log Format (CLF) line for one request/response pair:
IP - - [DD/Mon/YYYY:HH:MM:SS +0000] "METHOD URI VERSION" STATUS SIZE