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 creating Action instances, and publishing those actions to sinks.

  • 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 with Logger.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.

Logger.debug(action_name, **kw)[source]

Returns a new DEBUG-level Action named name., **kw)[source]

Returns a new INFO-level Action named name.

Logger.critical(action_name, **kw)[source]

Returns a new CRITICAL-level Action named name.

The action level can also be passed in:

Logger.action(level, action_name, **kw)[source]

Return a new Action named name classified as level.

Sink registration

Another vital aspect of Loggers is the registration and management of Sinks.


A copy of all sinks set on this Logger. Set sinks with Logger.set_sinks().


Add sink to this Logger’s sinks. Does nothing if sink is already in this Logger’s sinks.


Replace this Logger’s sinks with sinks.


Clear this Logger’s sinks.

Event handling

The event handling portion of the Logger API exists for Logger-Sink interactions.


Publish begin_event to all sinks with on_begin() hooks.


Publish end_event to all sinks with on_end() hooks.


Publish warn_event to all sinks with on_warn() hooks.

Logger.on_exception(exc_event, exc_type, exc_obj, exc_tb)[source]

Publish exc_event to all sinks with on_exception() hooks.