|
ACTS
Experiment-independent tracking
|
Subsystem for logging and message handling.
The ACTS logging system provides flexible, hierarchical logging with multiple severity levels and decorators. Logger objects can easily be created using the Acts::getDefaultLogger function which should be sufficient to get you started. In case you need more customized debug output, you can make use of the output decorators defined in Acts::Logging or even write your own implementation of Acts::Logging::OutputDecorator.
The logging system supports the following severity levels (from lowest to highest):
When a logger accessible via the logger() method, see Logging Patterns, use these macros to perform the actual logging:
The macros support stream-style formatting with << operators.
ACTS provides several patterns for integrating logging into your code, each suited for different use cases.
Use this pattern when a class needs persistent logging throughout its lifetime. The logger is stored as a member variable and passed to the constructor.
Best for:
Key characteristics:
Use this pattern when a function or algorithm should accept a logger from the caller, providing maximum flexibility.
Best for:
Key characteristics:
Use this pattern when logging is optional or should be disabled by default. In contract to getDefaultLogger, this function returns a logger that discards all messages, resulting in negligible runtime overhead. It is useful in cases where you don't want to default to logging to std::cout, but not all call-sites give you easy access to a logger.
Best for:
Key characteristics:
Use this function to create standalone loggers with standard formatting (timestamp, component name, log level). Note that the loggers returned by this function will always look to standard output streams (e.g. std::cout).
Acts::getDefaultLogger accepts an optional output stream parameter:
Loggers can be cloned to create independent instances with optional modifications to the name and/or log level. This is particularly useful when creating sub-component loggers or when you need multiple loggers with similar configurations.
Sub-component loggers: When a class has multiple internal components that need separate logging:
Per-component log levels: When building detectors or systems with different verbosity needs:
Testing: Creating test loggers with specific configurations:
In case you are using ACTS in another framework which comes with its own logging facility (e.g. Gaudi) you can pipe the logging output from ACTS tools and algorithms to your framework's logging system by supplying different implementations of:
There are two approaches to logger integration:
Overriding getDefaultLogger (now discouraged). This has the downside that log levels cannot be controlled from top-level experiment specific code. This means that it is non-trivial to steer the log level of an e.g. Gaudi algorithm via the OutputLevel property, and have the ACTS code respect this log level.
Since ACTS makes extensive use of Acts::getDefaultLogger to provide sufficient information for debugging, you might want to provide a modified implementation of this function (using your output filter and printing policies) to also pipe this output to your framework. You can use the LD_PRELOAD approach by providing an appropriate implementation for a function of the following signature into a separate source file and compile it in a shared library:
Then you can run your executable with:
Generally, log levels in ACTS are only of informative value: even Acts::Logging::Level::ERROR and Acts::Logging::Level::FATAL will only print messages, and not terminate execution.
This is desirable in an experiment context, where jobs should not immediately terminate when ACTS encounters something that is logged as an error. In a test context, however, this behavior is not optimal: the tests should ensure in known configurations errors do not occur, or only in specific circumstances. To solve this, ACTS implements an optional log threshold mechanism.
The threshold mechanism is steered via two CMake options: ACTS_ENABLE_LOG_FAILURE_THRESHOLD and ACTS_LOG_FAILURE_THRESHOLD. Depending on their configuration, the logging can operate in three modes:
Two main functions exist to interact with the failure threshold:
Topics | |
| Logging Macros | |
| Helper macros for logging with Acts::Logger. | |
| Logging Thresholds | |
| Functions and classes to manage logging failure thresholds. | |
Classes | |
| class | Acts::Logger |
| class for printing debug output More... | |
| class | Acts::Logging::DefaultFilterPolicy |
| default filter policy for debug messages More... | |
| class | Acts::Logging::DefaultPrintPolicy |
| default print policy for debug messages More... | |
| class | Acts::Logging::LevelOutputDecorator |
| decorate debug message with its debug level More... | |
| class | Acts::Logging::NamedOutputDecorator |
| decorate debug message with a name More... | |
| class | Acts::Logging::OutputDecorator |
| base class for decorating the debug output More... | |
| class | Acts::Logging::OutputFilterPolicy |
| abstract base class for filtering debug output More... | |
| class | Acts::Logging::OutputPrintPolicy |
| abstract base class for printing debug output More... | |
| class | Acts::Logging::ThreadOutputDecorator |
| decorate debug message with a thread ID More... | |
| class | Acts::Logging::TimedOutputDecorator |
| decorate debug message with a time stamp More... | |
Enumerations | |
| enum | Acts::Logging::Level { Acts::Logging::VERBOSE = 0 , Acts::Logging::DEBUG , Acts::Logging::INFO , Acts::Logging::WARNING , Acts::Logging::ERROR , Acts::Logging::FATAL , Acts::Logging::MAX } |
| constants steering the debug output More... | |
Functions | |
| std::string_view | Acts::Logging::levelName (Level level) |
| Get the string name for a logging level. | |
| enum Acts::Logging::Level |
constants steering the debug output
All messages with a debug level equal or higher than the currently set debug output level will be printed.
| std::string_view Acts::Logging::levelName | ( | Level | level | ) |
Get the string name for a logging level.
| level | The logging level |