Skip to main content

Crate charmed_log

Crate charmed_log 

Source
Expand description

§Charmed Log

A structured logging library designed for terminal applications.

Charmed Log provides beautiful, structured logging output with support for:

  • Multiple log levels (trace, debug, info, warn, error, fatal)
  • Structured key-value pairs
  • Multiple output formatters (text, JSON, logfmt)
  • Integration with lipgloss for styled output

§Role in charmed_rust

Charmed Log is the logging spine for TUI applications in this repo:

  • wish uses it for SSH session logging and diagnostics.
  • demo_showcase uses it for traceable, styled logs in tests and demos.
  • lipgloss supplies the styling used in human-readable formatters.

§Example

use charmed_log::{Logger, Level};

let logger = Logger::new();
logger.info("Application started", &[("version", "1.0.0")]);

§Formatters

  • Text: Human-readable colored output (default)
  • JSON: Machine-readable JSON output
  • Logfmt: Key=value format for log aggregation

Modules§

keys
Standard keys used in log records.
prelude
Prelude module for convenient imports.

Structs§

CallerInfo
Caller information extracted from the call stack.
Logger
A structured logger instance.
Options
Logger options.
ParseLevelError
Error returned when parsing an invalid log level string.
Styles
Styles for the text formatter.

Enums§

Formatter
Output formatter type.
Level
Log level for filtering messages.

Constants§

DEFAULT_TIME_FORMAT
Default time format.

Functions§

long_caller_formatter
Long caller formatter - returns full path and line.
now_utc
Returns the time in UTC.
short_caller_formatter
Short caller formatter - returns last 2 path segments and line.

Type Aliases§

CallerFormatter
Type alias for caller formatter.
ErrorHandler
Type alias for error handler callback.
ParseResult
A specialized Result type for level parsing operations.
TimeFunction
Type alias for time function.