lenskit.logging.tracing#
Extended logger providing TRACE support.
Functions
|
Mark tracing as active (or inactive). |
|
Get a tracer for efficient low-level tracing of computations. |
|
No-op filtering logger. |
|
Emit a trace-level message, if LensKit tracing is enabled. |
Query whether tracing is active. |
Classes
|
Active tracer that actually sends trace messages. |
|
Logger-like thing that is only for TRACE-level events. |
|
Class for LensKit loggers with trace-level logging support. |
- lenskit.logging.tracing.activate_tracing(active=True)#
Mark tracing as active (or inactive).
Global tracing state is just used to short-cut tracing. This method should only be called from
LoggingConfig
.
- lenskit.logging.tracing.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:
logger (BoundLogger)
args (Any)
kwargs (Any)
- lenskit.logging.tracing.get_tracer(logger, **initial_values)#
Get a tracer for efficient low-level tracing of computations.
- Stability:
Experimental
- Parameters:
logger (str | BoundLogger)
initial_values (Any)
- class lenskit.logging.tracing.Tracer(logger)#
Bases:
object
Logger-like thing that is only for TRACE-level events.
This class is designed to support structured tracing without the overhead of creating and binding new loggers. It is also imperative, rather than functional, so we create fewer objects and so it is a little more ergonomic for common tracing flows.
Note
Don’t create instances of this class directly — use
get_tracer()
to create a tracer.- Stability:
Experimental
- Parameters:
logger (BoundLogger)
- add_bindings(**new_values)#
Bind new data in the keys.
Note
Unlike
structlog.Logger.bind()
, this method is **imperative*: it updates the tracer in-place instead of returning a new tracer. If you need a new, disconnected tracer, usesplit()
.- Parameters:
new_values (Any)
- Return type:
None
- remove_bindings(*keys)#
Unbind keys in the tracer.
Note
Unlike
structlog.Logger.bind()
, this method is **imperative*: it updates the tracer in-place instead of returning a new tracer. If you need a new, disconnected tracer, usesplit()
.- Parameters:
keys (str)
- Return type:
None
- reset()#
Reset this tracer’s underlying logger to the original logger.
- Return type:
None
- class lenskit.logging.tracing.ActiveTracer(logger)#
Bases:
Tracer
Active tracer that actually sends trace messages.
- Parameters:
logger (BoundLogger)
- add_bindings(**new_values)#
Bind new data in the keys.
Note
Unlike
structlog.Logger.bind()
, this method is **imperative*: it updates the tracer in-place instead of returning a new tracer. If you need a new, disconnected tracer, usesplit()
.- Parameters:
new_values (Any)
- Return type:
None
- remove_bindings(*keys)#
Unbind keys in the tracer.
Note
Unlike
structlog.Logger.bind()
, this method is **imperative*: it updates the tracer in-place instead of returning a new tracer. If you need a new, disconnected tracer, usesplit()
.- Parameters:
keys (str)
- Return type:
None
- reset()#
Reset this tracer’s underlying logger to the original logger.
- Return type:
None
- class lenskit.logging.tracing.TracingLogger(logger, processors, context)#
Bases:
BoundLogger
Class for LensKit loggers with trace-level logging support.
Code should not directly use the tracing logger — it should use the
trace()
function that intelligently checks the logger.- Parameters:
logger (WrappedLogger)
processors (Iterable[Processor])
context (Context)
- bind(**new_values)#
Return a new logger with new_values added to the existing ones.
- Parameters:
new_values (Any)
- Return type: