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§
Structs§
- Json
Encoded LogMsg - This effectively our log “schema” – adapters are expected to log a json-ified instance of this struct per-logging-line.
- Logging
Error - 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
- Source
Info - Tpfs
LogCfg
Enums§
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§
- Event
Observer - LogKV
Pair Name - The “key” portion of a loggable kv pair
- LogKV
Pair Value - The “value” portion of a loggable kv pair
- Loggable
- TpfsLog
- Primary interface for logging. This crate implements this trait as an extension to the
standard
log::Logtrait.
Functions§
- add_
log_ observer - log_
event - The top-level function that the macros call to do logging. It fetches the global logger
from the
logcrate withlog::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
nameandvaluefunctions 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.