OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system

The SeverityFilter is a wrapper for a logger that drops messages below a requested severity. More...

#include <SeverityFilter.hpp>

Inheritance diagram for SeverityFilter:

Public Types

using Ptr = SeverityFilterPtr
 
using ConstPtr = SeverityFilterConstPtr
 
- Public Types inherited from LoggerInterface
using Ptr = LoggerInterfacePtr
 
using ConstPtr = LoggerInterfaceConstPtr
 
enum  Severity {
  kDebugApi, kDebug, kInfo, kProgress,
  kWarning, kError, kCritical
}
 

Public Member Functions

LoggerInterfacePtr upstreamLogger () const
 Returns the logger wrapped by the filter. More...
 
void log (Severity severity, const Str &message) override
 Filter out messages based on severity before delegating to the upstreamLogger. More...
 
Filter Severity

Messages logged with a severity greater or equal to this will be displayed.

void setSeverity (LoggerInterface::Severity severity)
 Sets the minimum severity of message that will be passed on to the upstreamLogger. More...
 
LoggerInterface::Severity getSeverity () const
 Returns the minimum severity of message that will be passed on to the upstreamLogger. More...
 
bool isSeverityLogged (Severity severity) const override
 Check if given severity will be logged. More...
 
- Public Member Functions inherited from LoggerInterface
virtual ~LoggerInterface ()
 Defaulted polymorphic destructor. More...
 
virtual void log (Severity severity, const Str &message)=0
 Logs a message to the user. More...
 
virtual bool isSeverityLogged (Severity severity) const
 Check if a given severity level should/will be filtered out. More...
 
void debugApi (const Str &message)
 
void debug (const Str &message)
 
void info (const Str &message)
 
void progress (const Str &message)
 
void warning (const Str &message)
 
void error (const Str &message)
 
void critical (const Str &message)
 

Static Public Member Functions

static SeverityFilterPtr make (LoggerInterfacePtr upstreamLogger)
 Creates a new instance of the SeverityFilter. More...
 

Additional Inherited Members

- Static Public Attributes inherited from LoggerInterface
static constexpr std::array kSeverityNames
 

Detailed Description

The SeverityFilter is a wrapper for a logger that drops messages below a requested severity.

More severe messages are relayed.

Environment Variables:
OPENASSETIO_LOGGING_SEVERITY [int] If set, the default displaySeverity for the filter is set to the value of the env var.

Member Typedef Documentation

Member Function Documentation

LoggerInterface::Severity getSeverity ( ) const

Returns the minimum severity of message that will be passed on to the upstreamLogger.

See also
LoggerInterface.Severity
bool isSeverityLogged ( Severity  severity) const
override

Check if given severity will be logged.

Uses the value of getSeverity() as well as querying the upstreamLogger, and returns the most pessimistic answer.

This logic is used in log to determine which messages to filter out.

Parameters
severitySeverity to check.
Returns
Whether a log message at the given severity will be output.
void log ( Severity  severity,
const Str message 
)
override

Filter out messages based on severity before delegating to the upstreamLogger.

Whether a log is output or not obeys the result of isSeverityLogged

Parameters
severitySeverity level.
messageThe message to be logged.
static SeverityFilterPtr make ( LoggerInterfacePtr  upstreamLogger)
static

Creates a new instance of the SeverityFilter.

The filter defaults to the kWarning severity.

Parameters
upstreamLoggerA logger that will receive messages of the requested severity or above.
See also
LoggerInterface.Severity
void setSeverity ( LoggerInterface::Severity  severity)

Sets the minimum severity of message that will be passed on to the upstreamLogger.

Parameters
severityThe minimum severity.
See also
LoggerInterface.Severity
LoggerInterfacePtr upstreamLogger ( ) const

Returns the logger wrapped by the filter.


The documentation for this class was generated from the following file:
  • /src/src/openassetio-core/include/openassetio/log/SeverityFilter.hpp