Crate ccb

Source
Expand description

§CCB Logger

A beautiful, terminal-focused structured logger designed for modern CLI applications.

CCB provides an elegant logging experience with semantic log levels, automatic color detection, structured context support, and high-precision timestamps. It’s built from the ground up to deliver exceptional visual clarity and developer experience.

§Quick Start

use ccb::{info, warn, error};

fn main() {
    info!("Application started");
    warn!("Configuration issue detected", "file", "config.toml");
    error!("Failed to connect", "host", "localhost", "port", "8080");
}

§Features

  • Five semantic log levels: Trace, Debug, Info, Warn, Error
  • Automatic color detection: Beautiful colored output with terminal compatibility
  • High-precision timestamps: Microsecond precision with clean formatting
  • Structured logging: Chain context with with(key, value) method
  • Convenient macros: Easy-to-use macros with variadic key-value pairs
  • Global logger support: Set and use application-wide logger configuration
  • Zero dependencies on icons: Maximum terminal compatibility

§Custom Logger Configuration

use ccb::{Logger, Level, set_global_logger};

let logger = Logger::new()
    .with_level(Level::Debug)
    .with_colors(true)
    .with("service", "auth")
    .with("version", "1.2.0");

set_global_logger(logger);

Macros§

debug
Macro for debug level logging
error
Logs a message at error level using the global logger.
info
Logs a message at info level using the global logger.
trace
Logs a message at trace level using the global logger.
warn
Logs a message at warn level using the global logger.

Structs§

Config
Configuration settings for logger behavior and output formatting.
LogEntry
Represents a single log entry with all associated metadata.
Logger
A structured logger with configurable output formatting and context management.

Enums§

Level
Represents the severity level of a log message.

Functions§

global_logger
Returns a clone of the current global logger.
set_global_logger
Sets the global logger instance used by logging macros.
with_global_logger
Executes a closure with access to the global logger.