Crate citadel_logging

Crate citadel_logging 

Source
Expand description

§Citadel Logging

A structured logging facade for the Citadel Protocol, built on top of the tracing ecosystem. This crate provides consistent logging setup and configuration across all Citadel Protocol components.

§Features

  • Structured logging with spans and events
  • File and line number information
  • Environment-based log level filtering
  • Panic handling with logging
  • Async-aware instrumentation

§Usage

use citadel_logging::{setup_log, info, debug, error};

// Initialize logging
setup_log();

// Log at different levels

info!(target: "citadel", "Starting application...");
debug!(target: "citadel", "Configuration loaded: {:?}", config);
error!(target: "citadel", "Failed to connect: {}", error);

§Log Levels

The following log levels are available, in order of increasing severity:

  • trace: Very detailed information for debugging
  • debug: Useful debugging information
  • info: General information about program execution
  • warn: Potentially harmful situations
  • error: Error conditions that should be addressed

§Environment Configuration

Log levels can be configured via the RUST_LOG environment variable:

# Enable debug logging for citadel components
RUST_LOG=citadel=debug

# Enable different levels for different components
RUST_LOG=citadel=debug,citadel_wire=trace

§Panic Handling

By default, setup_log() installs a panic hook that logs the panic information before exiting. If you need to use a custom panic hook, use setup_log_no_panic_hook() instead.

Re-exports§

pub use tracing;

Modules§

instrument
Attach a span to a std::future::Future.

Macros§

debug
Constructs an event at the debug level.
error
Constructs an event at the error level.
info
Constructs an event at the info level.
trace
Constructs an event at the trace level.
warn
Constructs an event at the warn level.

Functions§

setup_log
Sets up logging with panic handling for any Citadel Protocol crate.
setup_log_no_panic_hook
Sets up logging without installing a panic hook.
should_panic_test
Disables the panic hook installed by setup_log().