lenskit.logging#

Logging, progress, and resource records.

Submodules#

multiprocess

Multiprocess logging support for Ray integration. Most code doesn't need to

progress

tasks

Abstraction for recording tasks.

Attributes#

Classes#

LoggingConfig

Configuration for LensKit logging.

ResourceMeasurement

Single measurement of resources. Two measurements can be subtracted to

Stopwatch

Timer class for recording elapsed wall time in operations.

Tracer

Logger-like thing that is only for TRACE-level events.

Functions#

basic_logging([level])

Simple one-function logging configuration for simple command lines.

notebook_logging([level])

Simple one-function logging configuration for notebooks and similar.

stdout_console()

Get a console attached to stdout.

friendly_duration(elapsed)

Short, human-friendly representation of a duration.

get_logger(name, *[, remove_private])

Get a logger. This works like structlog.stdlib.get_logger(), except

get_tracer(logger, **initial_values)

Get a tracer for efficient low-level tracing of computations.

trace(logger, *args, **kwargs)

Emit a trace-level message, if LensKit tracing is enabled. Trace-level

Package Contents#

lenskit.logging.basic_logging(level=logging.INFO)#

Simple one-function logging configuration for simple command lines.

Stability:
Caller (see Stability Levels).
Parameters:

level (int)

lenskit.logging.notebook_logging(level=logging.INFO)#

Simple one-function logging configuration for notebooks and similar.

Stability:
Caller (see Stability Levels).
Parameters:

level (int)

lenskit.logging.console#
lenskit.logging.stdout_console()#

Get a console attached to stdout.

lenskit.logging.friendly_duration(elapsed)#

Short, human-friendly representation of a duration.

Parameters:

elapsed (float | datetime.timedelta)

lenskit.logging.get_logger(name, *, remove_private=True, **init_als)#

Get a logger. This works like structlog.stdlib.get_logger(), except the returned proxy logger is quiet (only WARN and higher messages) if structlog has not been configured. LensKit code should use this instead of obtaining loggers from Structlog directly.

It also suppresses private module name components of the logger name, so e.g. lenskit.pipeline._impl becomes ``lenskit.pipeline`.

Params:
name:

The logger name.

remove_private:

Set to False to keep private module components of the logger name instead of removing them.

init_vals:

Initial values to bind into the logger when crated.

Returns:

A lazy proxy logger. The returned logger is type-compatible with structlib.stdlib.BoundLogger, but is actually an instance of an internal proxy that provies more sensible defaults and handles LensKit’s TRACE-level logging support.

Parameters:
  • name (str)

  • remove_private (bool)

  • init_als (Any)

Return type:

structlog.stdlib.BoundLogger

lenskit.logging.get_tracer(logger, **initial_values)#

Get a tracer for efficient low-level tracing of computations.

Stability:

Experimental

Parameters:
lenskit.logging.trace(logger, *args, **kwargs)#

Emit a trace-level message, if LensKit tracing is enabled. Trace-level messages are more fine-grained than debug-level messages, and you usually don’t want them.

This function does not work on the lazy proxies returned by get_logger() and similar — it only works on bound loggers.

Stability:
Caller (see Stability Levels).
Parameters:

Exported Aliases#

class lenskit.logging.Progress#

Re-exported alias for lenskit.logging.progress.Progress.

lenskit.logging.item_progress()#

Re-exported alias for lenskit.logging.progress.item_progress().

lenskit.logging.set_progress_impl()#

Re-exported alias for lenskit.logging.progress.set_progress_impl().

class lenskit.logging.Task#

Re-exported alias for lenskit.logging.tasks.Task.