Skip to main content

Crate tpfs_logger_port

Crate tpfs_logger_port 

Source
Expand description

This module exposes a clean logging interface for all our code. The macros are really the interface here, and there is an expectation that any adapter will provide an init or similar method that registers as the global logger as per the log crate.

The provided macros provide an alternate version of the standard macros provided by log, where they expect to be passed Loggable events rather than format strings.

So, we heavily lean on the log crate as it’s the de-facto standard right now in the community

Re-exports§

pub use log;

Modules§

macros

Macros§

debug
error
info
trace
warn

Structs§

JsonEncodedLogMsg
This effectively our log “schema” – adapters are expected to log a json-ified instance of this struct per-logging-line.
LoggingError
This error type wraps a logger adapter’s internal error type to include the event it was trying to log at the time, allowing us to avoid needing to clone an event to alert in the event of logging failure
SourceInfo
TpfsLogCfg

Enums§

LogError

Constants§

HUMAN_READABLE_ENV_VAR
If this environment variable is present, adapter implementations are expected to produce human readable output rather than json output.
LOG_LEVEL_ENV_VAR
Use this environment variable to adjust the default logging level
LOG_PID_ENV_VAR
If this env var is set to any value, log process pids as well
LOG_TARGET_LEVEL_ENV_VAR
Use this environment variable to adjust logging levels for specific targets. The format of the environment variable is: path::to::module=level;path::to:another=level

Traits§

EventObserver
LogKVPairName
The “key” portion of a loggable kv pair
LogKVPairValue
The “value” portion of a loggable kv pair
Loggable
TpfsLog
Primary interface for logging. This crate implements this trait as an extension to the standardlog::Log trait.

Functions§

add_log_observer
log_event
The top-level function that the macros call to do logging. It fetches the global logger from the log crate with log::logger(), and then logs into that.

Attribute Macros§

logging_event
This macro is used to break up an enum into structs of the same shape, auto-derive an implementation of the name and value functions in the [tpfs_logger_port::LogKVPair] trait, and create a mod that replaces the enum but with the same name–to be more reader-friendly.