openinfra-logger 0.1.0

Universal structured logging — zero-dependency, RFC 8259-compliant JSON, file + console transports. Sibling implementations exist for Node.js, Python and Go with identical JSON output.
Documentation
  • Coverage
  • 18.18%
    2 out of 11 items documented0 out of 6 items with examples
  • Size
  • Source code size: 19.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 368.66 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • jonathascordeiro20/openinfra-logger
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jonathascordeiro20

openinfra-logger (Rust)

Crates.io docs.rs License

OpenInfra Logger — zero-dependency, RFC 8259-compliant structured logging. The same JSON shape is emitted by sibling implementations for Node.js, Python and Go, so polyglot stacks see a single, consistent log format.

Install

[dependencies]
openinfra-logger = "0.1"

Quickstart

use openinfra_logger::{Logger, Config};
use std::collections::HashMap;

fn main() {
    let logger = Logger::new(Config::default());
    let mut md = HashMap::new();
    md.insert("user_id".to_string(), "u_8821".to_string());
    md.insert("card".to_string(), "4111-1111-1111-1111".to_string());

    logger.log("order.placed", "info", md);
    // → {"timestamp":"…","level":"info","message":"order.placed","user_id":"u_8821","card":"4111-1111-1111-1111"}
}

Configuration

use openinfra_logger::{Logger, Config};
use std::collections::HashMap;

let mut defaults = HashMap::new();
defaults.insert("service".to_string(), "payment-gateway".to_string());

let cfg = Config {
    transports: vec!["console".to_string(), "file".to_string()],
    file_path: "./production.log".to_string(),
    default_metadata: defaults,
};

let logger = Logger::new(cfg);
logger.log("Payment processed", "info", HashMap::new());

Why zero-dependency

This crate compiles with no transitive crates — only std. The trade-off:

  • ✅ Faster compile, smaller binaries, no supply-chain surface, no serde version churn
  • ✅ Works in no_std-adjacent environments after minimal porting
  • ⚠️ The JSON builder is hand-rolled but RFC 8259-compliant (quotes, backslashes, control chars all escaped)
  • ⚠️ Metadata values are String in this version; structured/typed values land in 0.2.

Links

License

MIT — see LICENSE.