fastcs.tracer#

Members

Tracer

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 own Tracer, such as fastcs.launch. When enabled, any event logged from the object, or from another Tracer that uses the object as the topic, will be logged.

Note: The global logger level must be set to TRACE for the messages to be logged

Example 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 Tracer related to this event to enable it to be logged

  • args – Positional arguments for underlying logger

  • kwargs – Keyword arguments for underlying logger

enable_tracing()[source]#

Enable trace logging for this object

disable_tracing()[source]#

Disable trace logging for this object

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

remove_tracing_filter(key: str, value: Any)[source]#

Remove a specific key-value pair from the filter

Parameters:
  • key – An existing filter key

  • value – The allowed value to remove

clear_tracing_filters()[source]#

Clear all filters and allow all messages to be logged (if enabled)