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

An abstract base class that defines the receiving interface for log messages generated a manager or the API middleware. More...

#include <LoggerInterface.hpp>

Inheritance diagram for LoggerInterface:

Public Types

using Ptr = LoggerInterfacePtr
 
using ConstPtr = LoggerInterfaceConstPtr
 

Public Member Functions

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

Conveniences, equivalent to calling log with the corresponding Severity.

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)
 

Log Severity

enum  Severity {
  kDebugApi, kDebug, kInfo, kProgress,
  kWarning, kError, kCritical
}
 
static constexpr std::array kSeverityNames
 

Detailed Description

An abstract base class that defines the receiving interface for log messages generated a manager or the API middleware.

Note
OpenAssetIO makes use of shared pointers to facilitate object lifetime management across multiple languages. Instances passed into API methods via shared pointer may have their lifetimes extended beyond that of your code.

Member Typedef Documentation

Member Enumeration Documentation

enum Severity
strong
Enumerator
kDebugApi 
kDebug 
kInfo 
kProgress 
kWarning 
kError 
kCritical 

Constructor & Destructor Documentation

virtual ~LoggerInterface ( )
virtual

Defaulted polymorphic destructor.

Member Function Documentation

void critical ( const Str message)
void debug ( const Str message)
void debugApi ( const Str message)
void error ( const Str message)
void info ( const Str message)
virtual bool isSeverityLogged ( Severity  severity) const
virtual

Check if a given severity level should/will be filtered out.

The implementation of the logger may have a mechanism by which certain severity levels are not output. If a severity level is not output, then constructing a string to pass to the logger is wasted effort. This method can be queried before constructing a complex string, in order to avoid that wasted effort.

Implementors of LoggerInterface subclasses should override this method if they wish to conditionally skip logging at particular severity levels.

If log is called regardless, with a severity that elicits a false response from this method, then the logger may still output the message, but it is not guaranteed (and is discouraged).

The default implementation returns true for all severities.

Parameters
severitySeverity level to check.
Returns
Whether a message will be output if log is called with the given severity.
virtual void log ( Severity  severity,
const Str message 
)
pure virtual

Logs a message to the user.

This method must be implemented to present the supplied message to the user in an appropriate fashion.

Parameters
severityOne of the severity constants defined in Severity.
messageThe message string to be logged.

Implemented in ConsoleLogger.

void progress ( const Str message)
void warning ( const Str message)

Member Data Documentation

constexpr std::array kSeverityNames
static
Initial value:
{"debugApi", "debug", "info", "progress",
"warning", "error", "critical"}

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