Skip to main content

Crate log_io

Crate log_io 

Source
Expand description

Structured logging pipeline for Rust.

log-io is an IO pipeline for structured log records. It is not a wrapper around log or tracing. A record flows through a small number of well-defined stages: filter, format, sink. Each stage is independently composable.

§Quick start

use log_io::{Field, Level, Logger, Value};

let logger = Logger::builder()
    .level(Level::Info)
    .stdout_json()
    .build();

logger.log(
    Level::Info,
    "server started",
    &[Field::new("port", Value::U64(8080))],
);

§Features

  • std (default): enables IO sinks, file output, async-safe locks, thread-local context propagation, and timestamps. When disabled, the crate compiles in no_std mode with only the data model and core::fmt::Write-based formatters available.
  • json (default): JSON output format.
  • logfmt (default): key=value logfmt output format.
  • human (default): human-readable format with aligned columns and RFC 3339 timestamps. no_std-compatible.

§Design notes

The fast path is allocation-free in steady state. Record, Field, and Value all borrow their data. Formatters serialize directly into a writer; the built-in sinks use a thread-local scratch buffer so per-record formatting does not touch the allocator after the first call.

§Stability

1.x.y releases preserve backwards compatibility. The full public API surface is documented in REPS.md section 4 and exhaustively in docs/API.md.

Re-exports§

pub use crate::format::Format;
pub use crate::sink::Sink;std

Modules§

contextstd
Thread-local logging context.
format
Output formats.
sinkstd
Output sinks.

Macros§

debugstd
Emit a crate::Level::Debug record.
errorstd
Emit a crate::Level::Error record.
infostd
Emit a crate::Level::Info record.
log_atstd
Emit a log record at the given level.
tracestd
Emit a crate::Level::Trace record.
warnstd
Emit a crate::Level::Warn record.

Structs§

Field
A single key-value pair attached to a Record.
Filterstd
A target-aware severity gate.
FilterRulestd
One rule in a Filter.
Loggerstd
The configured log pipeline.
LoggerBuilderstd
Builder for Logger. Construct with Logger::builder.
Metadata
Metadata describing the origin and severity of a record.
ParseFilterErrorstd
Error returned by Filter::parse when a directive segment is malformed.
ParseLevelError
Error returned when a string cannot be parsed as a Level.
Record
A complete, immutable log record.

Enums§

Errorstd
Errors produced by the logging pipeline.
Level
Severity of a log record.
Value
A field value attached to a log record.

Constants§

VERSION
Crate version string, populated by Cargo at build time.

Type Aliases§

Resultstd
Crate result alias.