pub fn scope<SF, R>(logger: &Logger, f: SF) -> Rwhere
SF: FnOnce() -> R,
Expand description
Execute code in a logging scope
Logging scopes allow using a slog::Logger
without explicitly
passing it in the code.
At any time current active Logger
for a given thread can be retrived
with logger()
call.
Logging scopes can be nested and are panic safe.
logger
is the Logger
to use during the duration of f
.
with_current_logger
can be used to build it as a child of currently active
logger.
f
is a code to be executed in the logging scope.
Note: Thread scopes are thread-local. Each newly spawned thread starts with a global logger, as a current logger.