Namespace Acts::Logging

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

Level getFailureThreshold()

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

All messages with a debug level equal or higher than the return value of this function 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 level will cause an exception to be thrown after log emission.

Note

This function is only available if ACTS_LOG_FAILURE_THRESHOLD is unset, i.e. no compile-time threshold is used. Otherwise an exception is thrown.

Warning

The runtime log failure threshold is global state, therefore this function is not threadsafe. The intention is that this level is set once, before multi-threaded execution begins, and then not modified before the end of the 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(Level lvl)

constructor

Parameters

lvl[in] threshold debug level

~DefaultFilterPolicy() override = default

virtual default destructor

inline virtual std::unique_ptr<OutputFilterPolicy> clone(Level level) const override

Make a copy of this filter policy with a new level.

Parameters

level – the new level

Returns

the new copy

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

inline virtual Level level() const override

Get the level of this filter policy.

Returns

the levele

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const override

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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

inline virtual const std::string &name() const override

Fulfill OutputPrintPolicy interface.

This policy doesn’t actually have a name, so the assumption is that somewhere in the decorator hierarchy, there is something that returns a name without delegating to a wrappee, before reaching this overload.

Note

This method will throw an exception

Returns

the name, but it never returns

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const override

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const override

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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

inline virtual const std::string &name() const override

Get this named output decorators name.

Returns

the name

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

inline virtual const std::string &name() const override

Return the name of the output decorator (forwards to wrappee)

Returns

the name

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 std::unique_ptr<OutputFilterPolicy> clone(Level level) const = 0

Make a copy of this filter policy with a new level.

Parameters

level – the new level

Returns

the new copy

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

virtual Level level() const = 0

Get the level of this filter policy.

Returns

the levele

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const = 0

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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

virtual const std::string &name() const = 0

Return the name of the print policy.

Returns

the name

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const override

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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 std::unique_ptr<OutputPrintPolicy> clone(const std::string &name) const override

Make a copy of this print policy with a new name.

Parameters

name – the new name

Returns

the copy

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