Expand description
Centralized logging setup for the whole framework.
init installs a global tracing_subscriber once at application boot.
Everything that emits tracing events then flows through it:
- HTTP requests/responses —
doido-controller’slogging::log_requestsmiddleware logs arequestand aresponseline atINFO, correlated by a sharedrequest_id. - ORM queries —
doido-model’s connection enables sea-orm’s SQL logging, which emitstracingevents under targetsqlx::query. - Jobs, mail, custom events — the helpers in
crate::trace.
Applications configure the logger from the logger section of
config/<env>.yml, deserialized into LoggerConfig and applied via
init_with_config. That controls the verbosity (built from a log level
or an explicit directives filter), whether output is redirected to a
file, and whether sea-orm emits sql statement logs. Because sea-orm logs
through this same subscriber, redirecting to a file captures SQL too.
The RUST_LOG environment variable, when set, overrides the configured
verbosity (env vars win over config, matching the rest of the framework).
Structs§
- Logger
Config - Logging settings, deserialized from the
loggersection ofconfig/<env>.yml.
Enums§
- LogFormat
- How log events are rendered.
Constants§
- DEFAULT_
DIRECTIVES - Default
EnvFilterdirectives whenRUST_LOGis unset. - NOISE_
DIRECTIVES - Framework targets quieted below the application log level.
- REQUEST_
TARGET tracingtarget for the “request received” event emitted bydoido-controller’s logging middleware.- RESPONSE_
TARGET tracingtarget for the “response sent” event emitted bydoido-controller’s logging middleware.LogFormat::JsonResponseisolates this target.
Functions§
- directives_
for_ level - Builds
EnvFilterdirectives for an application loglevel(e.g.info,debug,warn), appending the frameworkNOISE_DIRECTIVESso SQL/HTTP internals stay quiet regardless of the chosen level. - init
- Installs the global tracing subscriber using
RUST_LOG(orDEFAULT_DIRECTIVES) and stdout output. Idempotent and safe to call more than once. - init_
with - Like
initbut usesdefault_directiveswhenRUST_LOGis unset. - init_
with_ config - Installs the global tracing subscriber from a
LoggerConfig: verbosity fromRUST_LOGor the config’sdirectives, output to the config’sfilewhen set (otherwise stdout), and rendering per the config’sformat. Idempotent and safe to call more than once; only the first call takes effect.