LuciadCPillar 2023.1.04
luciad::ILoggingBackend Class Referenceabstract

Backend for the logging in this library. More...

#include <luciad/ILoggingBackend.h>

Public Types

using Handle = void *
 Opaque handle for a logger created by the implementation. More...
 

Public Member Functions

 ILoggingBackend ()=default
 Creates an ILoggingBackend. More...
 
 ILoggingBackend (const ILoggingBackend &)=delete
 
virtual ~ILoggingBackend ()=default
 
virtual void deleteLogger (Handle handle)=0
 Indicates that the logger with the given handle is not used anymore. More...
 
virtual bool isEnabled (Handle handle, LogLevel level)=0
 Returns whether logging output is enabled for the specified logger at the given level. More...
 
virtual void log (Handle handle, LogLevel level, std::string message)=0
 This function will not be called if level is not enabled for logger. More...
 
virtual void log (Handle handle, LogLevel level, std::string message, const Exception &exception)=0
 This function will not be called if level is not enabled for logger. More...
 
virtual Handle newLogger (std::string name)=0
 Creates a new handle for a logger with the given name. More...
 
ILoggingBackendoperator= (const ILoggingBackend &)=delete
 

Detailed Description

Backend for the logging in this library.

Users can implement this backend to delegate the internal logging to their framework of choice. The implementation must then be configured during global initialization in order to be used by this library.

Implementations must be thread-safe. All methods will be called concurrently from various threads.

Note that the only purpose of this interface is to facilitate redirecting the logging performed by this library. We expect that, in your own code, you use your framework of choice directly.

Member Typedef Documentation

◆ Handle

Opaque handle for a logger created by the implementation.

Any calls to the backend that are associated to a specific logger provide the handle of that logger so that the implementation can identify the logger of interest.

Constructor & Destructor Documentation

◆ ILoggingBackend() [1/2]

luciad::ILoggingBackend::ILoggingBackend ( )
default

Creates an ILoggingBackend.

◆ ~ILoggingBackend()

virtual luciad::ILoggingBackend::~ILoggingBackend ( )
virtualdefault

◆ ILoggingBackend() [2/2]

luciad::ILoggingBackend::ILoggingBackend ( const ILoggingBackend )
delete

Member Function Documentation

◆ deleteLogger()

virtual void luciad::ILoggingBackend::deleteLogger ( Handle  handle)
pure virtual

Indicates that the logger with the given handle is not used anymore.

Implementations could delete the corresponding resource, if any.

Parameters
handlea handle previously returned by newLogger(std::string)

◆ isEnabled()

virtual bool luciad::ILoggingBackend::isEnabled ( Handle  handle,
LogLevel  level 
)
pure virtual

Returns whether logging output is enabled for the specified logger at the given level.

Parameters
handleidentifies a logger
levela specific logging level
Returns
whether logging output is enabled for the specified logger at the given level

◆ log() [1/2]

virtual void luciad::ILoggingBackend::log ( Handle  handle,
LogLevel  level,
std::string  message 
)
pure virtual

This function will not be called if level is not enabled for logger.

Parameters
handleidentifies a logger
levela specific logging level
messagethe message to log
See also
isEnabled()

◆ log() [2/2]

virtual void luciad::ILoggingBackend::log ( Handle  handle,
LogLevel  level,
std::string  message,
const Exception exception 
)
pure virtual

This function will not be called if level is not enabled for logger.

Parameters
handleidentifies a logger
levela specific logging level
messagethe message to log
exceptionthe exception associated with the message
See also
isEnabled()

◆ newLogger()

virtual Handle luciad::ILoggingBackend::newLogger ( std::string  name)
pure virtual

Creates a new handle for a logger with the given name.

At any time, at most one Handle is requested for a given name. This means that, unless a previously returned handle for a name is deleted , this function will be not be called again with that same name.

Parameters
namethe name of the logger that is requested
Returns
a handle for the new logger

◆ operator=()

ILoggingBackend & luciad::ILoggingBackend::operator= ( const ILoggingBackend )
delete