Module logging

Module logging 

Source
Expand description

Logging utilities (internal use).

Provides a single helper (init_from_dir) that installs a tracing subscriber based on an optional logging.yml file. This is invoked automatically by the top-level builder; applications normally do not call it directly.

§Configuration File: logging.yml (optional)

Keys:

  • filter – full tracing filter expression (takes precedence over level)
  • level – global fallback level (ignored if filter present)
  • ansi – enable/disable colored output (default: true)
  • format.with_timestamp – show timestamps (true) or hide them (false); omit for default (true)

§Defaults (file absent or field omitted)

  • level: info
  • ansi: true
  • timestamp: true

§Minimal Example

level: info

§Filter Example

filter: info,mycrate::sub=debug

§Hide Timestamps

filter: info
format:
  with_timestamp: false

Unknown keys are ignored. Parse errors fall back to defaults. Diagnostics (successful initialization or existing subscriber) are emitted at debug level via the active tracing subscriber.

§Diagnostics

  • On success, emits debug!(...) with details of the logging configuration.
  • If a subscriber is already installed, emits debug!(...) indicating this, and uses the existing configuration.

Structs§

LoggingSettings

Functions§

init_from_dir
Initialize tracing subscriber from a preferred directory or current working directory.
load_logging_settings
Load logging settings (filter, ansi, timestamp) without installing a subscriber. Public for testing.