Skip to main content

Module logger

Module logger 

Source
Expand description

Structured logging with JSON output and sensitive data masking.

Provides production-ready logging matching hyperi-pylib (Python) and hyperi-golib (Go). Automatically detects terminal vs container environment for format selection.

§Features

  • RFC 3339 timestamps with timezone
  • JSON output for containers, coloured text for terminals
  • Sensitive data masking (passwords, tokens, API keys)
  • Environment variable overrides (LOG_LEVEL, LOG_FORMAT, NO_COLOR)

§Example

use hyperi_rustlib::logger;

// Initialise with defaults (auto-detects format)
logger::setup_default().unwrap();

// Use tracing macros
tracing::info!(user_id = 123, "User logged in");
tracing::error!(error = "connection failed", "Database error");

Re-exports§

pub use helpers::log_debounced;
pub use helpers::log_sampled;
pub use helpers::log_state_change;
pub use security::SecurityEvent;
pub use security::SecurityOutcome;

Modules§

format
Custom coloured log formatter for terminal output.
helpers
Log spam protection helpers.
security
Structured security event logging following OWASP Logging Vocabulary.

Structs§

LoggerOptions
Logger configuration options.
MaskingLayer
Configuration for sensitive field detection.
MaskingWriter
A writer that redacts sensitive field values from formatted log output.
ThrottleConfig
Log throttle configuration.

Enums§

LogFormat
Log output format.
LoggerError
Logger errors.

Functions§

default_sensitive_fields
Default list of sensitive field names to mask.
mask_sensitive_string
Mask sensitive values in a string.
setup
Initialise the global logger with custom options.
setup_default
Initialise the global logger with default settings.