fastcs.tracer#
Members
A mixin or standalone class for conditionally logging trace events. |
- class fastcs.tracer.Tracer(name: str | None = None)[source]#
A mixin or standalone class for conditionally logging trace events.
This can be used for verbose logging that is disabled by default and enabled on a per-instance basis, with filtering based on specific key-value pairs on the event.
Any instance of this class can enable tracing independently. Some key classes inherit this class, such as
Attributes, and some modules have their ownTracer, such asfastcs.launch. When enabled, any event logged from the object, or from anotherTracerthat uses the object as thetopic, will be logged.Note: The global logger level must be set to
TRACEfor the messages to be loggedExample usage: .. code-block:: python
controller.ramp_rate.enable_tracing() controller.ramp_rate.disable_tracing() controller.connection.enable_tracing() controller.connection.add_tracing_filter(“query”, “V?”) controller.connection.remove_tracing_filter(“query”, “V?”) controller.connection.disable_tracing()
- Parameters:
name – The name of the logger. Attached to log messages as
logger_name.
- log_event(event: str, topic: Tracer | None = None, *args, **kwargs)[source]#
Log an event only if tracing is enabled and the filter matches
- Parameters:
event – A message describing the event
topic – Another
Tracerrelated to this event to enable it to be loggedargs – Positional arguments for underlying logger
kwargs – Keyword arguments for underlying logger
- add_tracing_filter(key: str, value: Any)[source]#
Add a filter for trace log messages from this object
To reduce trace messages further, a filter can be applied such that events must have a key with a specific value for it to be logged.
- Parameters:
key – A new or existing key to filter on
value – An allowed value for the event to be logged