Skip to main content

Crate cor

Crate cor 

Source
Expand description

cor — Colorize JSON-structured log lines from stdin.

This library provides the core parsing and formatting functionality for the cor CLI tool. It can parse JSON log lines from various frameworks (logrus, zap, slog, pino, bunyan, structlog), auto-detect timestamp, level, and message fields, and output colorized human-readable text.

§Example

use cor::{Config, format_line};

let config = Config::default();
let mut out = String::new();

format_line(r#"{"level":"info","msg":"hello","port":8080}"#, &config, false, &mut out);
assert!(out.contains("INFO"));
assert!(out.contains("hello"));

Re-exports§

pub use config::Config;
pub use error::CorError;
pub use formatter::format_line;
pub use formatter::format_line_parsed;
pub use level::Level;
pub use parser::LineKind;
pub use parser::LogRecord;
pub use parser::parse_line;
pub use parser::sanitize_json_newlines;
pub use parser::un_double_escape_json;
pub use timestamp::Timestamp;

Modules§

cli
Command-line argument definitions for cor.
config
Configuration management with TOML file support.
error
Error types for the cor application.
fields
Canonical field alias tables for auto-detecting common log fields.
formatter
Colorized output formatter for structured log entries.
level
Log level representation with parsing, display, and colorization.
parser
JSON log line parser with auto-detection and embedded JSON support.
timestamp
Timestamp parsing and formatting for structured log entries.