The Logger¶
The Logger
is the application developer’s primary
interface to using Lithoxyl. It is used to conveniently create
Actions
and publish them to sinks
.
-
class
lithoxyl.logger.
Logger
(name, sinks=None, **kwargs)[source]¶ The
Logger
is one of three core Lithoxyl types, and the main entrypoint to creatingAction
instances, and publishing those actions to sinks.Parameters: - name (str) – Name of this Logger.
- sinks (list) – A list of sink objects to be attached to
the Logger. Defaults to
[]
. Sinks can be added later withLogger.add_sink()
. - module (str) – Name of the module where the new Logger instance will be stored. Defaults to the module of the caller.
Most Logger methods and attributes fal into three categories:
Action
creation, Sink registration, and Event handling.
Action creation¶
The Logger is primarily used through its
Action
-creating convenience methods named
after various log levels: debug()
, info()
,
and critical()
.
Each creates a new action with a given name, passing any
additional keyword arguments on through to the
lithoxyl.action.Action
constructor.
The action level can also be passed in:
Sink registration¶
Another vital aspect of Loggers is the registration and management of Sinks.
-
Logger.
sinks
¶ A copy of all sinks set on this Logger. Set sinks with
Logger.set_sinks()
.
Event handling¶
The event handling portion of the Logger API exists for Logger-Sink interactions.