File Logger.hpp

Defines

ACTS_DEBUG(x)

macro for debug debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::DEBUG.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

ACTS_ERROR(x)

macro for error debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::ERROR.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

ACTS_FATAL(x)

macro for fatal debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::FATAL.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

ACTS_INFO(x)

macro for info debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::INFO.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

ACTS_LOCAL_LOGGER(log_object)

macro to use a local Acts::Logger object

This macro allows to use a locally defined logging object with the ACTS_* logging macros. The envisaged usage is the following:

void myFunction() {
   std::unique_ptr<const Acts::Logger> myLogger
       = /* .. your initialization .. */;
   ACTS_LOCAL_LOGGER(std::move(myLogger));

   ACTS_VERBOSE("hello world!");
}

Parameters
  • log_object – logger instance of type

Pre

In the current scope, the symbol logger is not yet defined.

Post

The ownership of the given log_object is transferred and log_object should not be used directly any more.

ACTS_LOG(level, x)
ACTS_VERBOSE(x)

macro for verbose debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::VERBOSE.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

ACTS_WARNING(x)

macro for warning debug output

The debug message is printed if the current Acts::Logging::Level <= Acts::Logging::WARNING.

Parameters
  • x – debug message

Pre

logger() must be a valid expression in the scope where this macro is used and it must return a Acts::Logger object.

namespace Acts

Note

This file is foreseen for the Geometry module to replace Extent

Functions

std::unique_ptr<const Logger> getDefaultLogger(const std::string &name, const Logging::Level &lvl, std::ostream *log_stream = &std::cout)

get default debug output logger

This function returns a pointer to a Logger instance with the following decorations enabled:

  • time stamps

  • name of logging instance

  • debug level

Parameters
  • name[in] name of the logger instance

  • lvl[in] debug threshold level

  • log_stream[in] output stream used for printing debug messages

Returns

pointer to logging instance

LoggerWrapper getDummyLogger()
class Logger
#include <Acts/Utilities/Logger.hpp>

class for printing debug output

This class provides the user interface for printing debug messages with different levels of severity.

Public Functions

inline Logger(std::unique_ptr<Logging::OutputPrintPolicy> pPrint, std::unique_ptr<Logging::OutputFilterPolicy> pFilter)

construct from output print and filter policy

Parameters
  • pPrint[in] policy for printing debug messages

  • pFilter[in] policy for filtering debug messages

inline bool doPrint(const Logging::Level &lvl) const

decide whether a message with a given debug level has to be printed

Parameters

lvl[in] debug level of debug message

Returns

true if debug message should be printed, otherwise false

inline void log(const Logging::Level &lvl, const std::string &input) const

log a debug message

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Members

std::unique_ptr<Logging::OutputFilterPolicy> m_filterPolicy

policy object for filtering debug messages

std::unique_ptr<Logging::OutputPrintPolicy> m_printPolicy

policy object for printing debug messages

class LoggerWrapper
#include <Acts/Utilities/Logger.hpp>

Class that contains (but doesn’t own) a logger instance.

Is callable so can be used with the logging macros.

Public Functions

LoggerWrapper() = delete
explicit LoggerWrapper(const Logger &logger)

Constructor ensuring a logger instance is given.

Parameters

logger

inline bool doPrint(const Logging::Level &lvl) const

Directly expose whether the contained logger will print at a level.

Parameters

lvl – The level to check

Returns

Whether to print at this level or not.

void log(const Logging::Level &lvl, const std::string &input) const

Add a logging message at a given level.

Parameters
  • lvl – The level to print at

  • input – text of debug message

inline const Logger &operator()() const

Call operator that returns the contained logger instance.

Enables using the logging macros ACTS_* when an instance of this class is assigned to a local variable logger.

Returns

Reference to the logger instance.

Private Members

const Logger *m_logger
namespace Logging

debug output related helper classes and functions

Enums

enum 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.

Values:

enumerator VERBOSE

VERBOSE level.

enumerator DEBUG

DEBUG level.

enumerator INFO

INFO level.

enumerator WARNING

WARNING level.

enumerator ERROR

ERROR level.

enumerator FATAL

FATAL level.

enumerator MAX

Must be kept above the maximum supported debug level.

Functions

constexpr Level getFailureThreshold()

Get debug level above which an exception will be thrown after logging.

All messages with a debug level equal or higher than FAILURE_THRESHOLD will cause an exception to be thrown after log emission.

Note

Depending on preprocessor settings ACTS_ENABLE_LOG_FAILURE_THRESHOLD and ACTS_LOG_FAILURE_THRESHOLD, this operations is either constexpr or a runtime operation.

inline std::string_view levelName(Level level)
void setFailureThreshold(Level level)

Set debug level above which an exception will be thrown after logging.

All messages with a debug level equal or higher than FAILURE_THRESHOLD will cause an exception to be thrown after log emission.

Note

This sets a global static runtime value, which is not thread-safe! This function should not be called during a job.

class DefaultFilterPolicy : public Acts::Logging::OutputFilterPolicy
#include <Acts/Utilities/Logger.hpp>

default filter policy for debug messages

All debug messages with a debug level equal or larger to the specified threshold level are processed.

Public Functions

inline explicit DefaultFilterPolicy(const Level &lvl)

constructor

Parameters

lvl[in] threshold debug level

~DefaultFilterPolicy() override = default

virtual default destructor

inline virtual bool doPrint(const Level &lvl) const override

decide whether a debug message should be processed

Parameters

lvl[in] debug level of debug message

Returns

true if lvl >= m_level, otherwise false

Private Members

Level m_level

threshold debug level for messages to be processed

class DefaultPrintPolicy : public Acts::Logging::OutputPrintPolicy
#include <Acts/Utilities/Logger.hpp>

default print policy for debug messages

This class allows to print debug messages without further modifications to a specified output stream.

Public Functions

inline explicit DefaultPrintPolicy(std::ostream *out = &std::cout)

constructor

Parameters

out[in] pointer to output stream object

Pre

out is non-zero

inline virtual void flush(const Level &lvl, const std::string &input) final

flush the debug message to the destination stream

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Members

std::ostream *m_out

pointer to destination output stream

class LevelOutputDecorator : public Acts::Logging::OutputDecorator
#include <Acts/Utilities/Logger.hpp>

decorate debug message with its debug level

The debug message is complemented with its debug level.

Public Functions

inline explicit LevelOutputDecorator(std::unique_ptr<OutputPrintPolicy> wrappee)

constructor

Parameters

wrappee[in] output print policy object to be wrapped

inline virtual void flush(const Level &lvl, const std::string &input) override

flush the debug message to the destination stream

This function prepends the debug level to the debug message and then delegates the flushing of the whole message to its wrapped object.

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Functions

inline std::string toString(const Level &lvl) const

convert debug level to string

Parameters

lvl[in] debug level

Returns

string representation of debug level

class NamedOutputDecorator : public Acts::Logging::OutputDecorator
#include <Acts/Utilities/Logger.hpp>

decorate debug message with a name

The debug message is complemented with a name.

Public Functions

inline NamedOutputDecorator(std::unique_ptr<OutputPrintPolicy> wrappee, const std::string &name, unsigned int maxWidth = 15)

constructor

Parameters
  • wrappee[in] output print policy object to be wrapped

  • name[in] name to be added to debug message

  • maxWidth[in] maximum width of field used for name

inline virtual void flush(const Level &lvl, const std::string &input) override

flush the debug message to the destination stream

This function prepends the given name to the debug message and then delegates the flushing of the whole message to its wrapped object.

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Members

unsigned int m_maxWidth

maximum width of field for printing the name

std::string m_name

name to be prepended

class OutputDecorator : public Acts::Logging::OutputPrintPolicy
#include <Acts/Utilities/Logger.hpp>

base class for decorating the debug output

Derived classes may augment the debug message with additional information. Chaining different decorators is possible to customize the output to your needs.

Subclassed by Acts::Logging::LevelOutputDecorator, Acts::Logging::NamedOutputDecorator, Acts::Logging::ThreadOutputDecorator, Acts::Logging::TimedOutputDecorator

Public Functions

inline explicit OutputDecorator(std::unique_ptr<OutputPrintPolicy> wrappee)

constructor wrapping actual output print policy

Parameters

wrappee[in] output print policy object which is wrapped by this decorator object

inline virtual void flush(const Level &lvl, const std::string &input) override

flush the debug message to the destination stream

This function delegates the flushing of the debug message to its wrapped object.

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Members

std::unique_ptr<OutputPrintPolicy> m_wrappee

wrapped object for printing the debug message

class OutputFilterPolicy
#include <Acts/Utilities/Logger.hpp>

abstract base class for filtering debug output

Implementations of this interface need to define whether a debug message with a certain debug level is processed or filtered out.

Subclassed by Acts::Logging::DefaultFilterPolicy

Public Functions

virtual ~OutputFilterPolicy() = default

virtual default destructor

virtual bool doPrint(const Level &lvl) const = 0

decide whether a debug message should be processed

Parameters

lvl[in] debug level of debug message

Returns

true of debug message should be processed, false if debug message should be skipped

class OutputPrintPolicy
#include <Acts/Utilities/Logger.hpp>

abstract base class for printing debug output

Implementations of this interface need to define how and where to print debug messages (e.g. to a file, to a stream into a database etc).

Subclassed by Acts::Logging::DefaultPrintPolicy, Acts::Logging::OutputDecorator

Public Functions

virtual ~OutputPrintPolicy() = default

virtual default destructor

virtual void flush(const Level &lvl, const std::string &input) = 0

handle output of debug message

Parameters
  • lvl[in] debug output level of message

  • input[in] text of debug message

class ThreadOutputDecorator : public Acts::Logging::OutputDecorator
#include <Acts/Utilities/Logger.hpp>

decorate debug message with a thread ID

The debug message is complemented with a thread ID.

Public Functions

inline explicit ThreadOutputDecorator(std::unique_ptr<OutputPrintPolicy> wrappee)

constructor

Parameters

wrappee[in] output print policy object to be wrapped

inline virtual void flush(const Level &lvl, const std::string &input) override

flush the debug message to the destination stream

This function prepends the thread ID to the debug message and then delegates the flushing of the whole message to its wrapped object.

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

class ThresholdFailure : public std::runtime_error
#include <Acts/Utilities/Logger.hpp>

Custom exception class so threshold failures can be caught.

class TimedOutputDecorator : public Acts::Logging::OutputDecorator
#include <Acts/Utilities/Logger.hpp>

decorate debug message with a time stamp

The debug message is complemented with a time stamp.

Public Functions

inline TimedOutputDecorator(std::unique_ptr<OutputPrintPolicy> wrappee, const std::string &format = "%X")

constructor

Parameters
  • wrappee[in] output print policy object to be wrapped

  • format[in] format of time stamp (see std::strftime)

inline virtual void flush(const Level &lvl, const std::string &input) override

flush the debug message to the destination stream

This function prepends a time stamp to the debug message and then delegates the flushing of the whole message to its wrapped object.

Parameters
  • lvl[in] debug level of debug message

  • input[in] text of debug message

Private Functions

inline std::string now() const

get current time stamp

Returns

current time stamp as string

Private Members

std::string m_format

format of the time stamp (see std::strftime for details)