openDAQ
Open data acquisition platform
ILogger Struct Referenceabstract

Represents a collection of Logger Components with multiple Logger Sinks and a single Logger Thread Pool shared between components. More...

+ Inheritance diagram for ILogger:
+ Collaboration diagram for ILogger:

Detailed Description

Represents a collection of Logger Components with multiple Logger Sinks and a single Logger Thread Pool shared between components.

Logger is used to create, manage and maintain Logger Components associated with different parts of the openDAQ SDK. The Logger provides methods, allowing for components to be added and removed dynamically. The components added within the same Logger object should have unique names. Each newly added component inherits threshold log severity level from the Logger. Then this level can be changed independently per component. The set of sinks is initialized on the Logger object creation and cannot be changed after.

Additionally, Logger provides the ability to manage flushing policies for the added components, see flushOnLevel method.

Public Member Functions

virtual ErrCode INTERFACE_FUNC setLevel (LogLevel level)=0
 Sets the default log severity level. More...
 
virtual ErrCode INTERFACE_FUNC getLevel (LogLevel *level)=0
 Gets the default log severity level. More...
 
virtual ErrCode INTERFACE_FUNC getOrAddComponent (IString *name, ILoggerComponent **component)=0
 Gets an added component by name or creates a new one with a given name and adds it to the Logger object. More...
 
virtual ErrCode INTERFACE_FUNC addComponent (IString *name, ILoggerComponent **component)=0
 Creates a component with a given name and adds it to the Logger object. More...
 
virtual ErrCode INTERFACE_FUNC removeComponent (IString *name)=0
 Removes the component with a given name from the Logger object. More...
 
virtual ErrCode INTERFACE_FUNC getComponents (IList **components)=0
 Gets a list of added components. More...
 
virtual ErrCode INTERFACE_FUNC getComponent (IString *name, ILoggerComponent **component)=0
 Gets an added component by name. More...
 
virtual ErrCode INTERFACE_FUNC flush ()=0
 Triggers writing out the messages stored in temporary buffers for added components and sinks associated with the Logger object.
 
virtual ErrCode INTERFACE_FUNC flushOnLevel (LogLevel level)=0
 Sets the minimum severity level of messages to be automatically flushed by components of Logger object. More...
 
- Public Member Functions inherited from IBaseObject
virtual ErrCode INTERFACE_FUNC borrowInterface (const IntfID &intfID, void **obj) const =0
 Returns another interface which is supported by the object without incrementing the reference count. More...
 
virtual ErrCode INTERFACE_FUNC dispose ()=0
 Disposes all references held by the object. More...
 
virtual ErrCode INTERFACE_FUNC getHashCode (SizeT *hashCode)=0
 Returns hash code of the object. More...
 
virtual ErrCode INTERFACE_FUNC equals (IBaseObject *other, Bool *equal) const =0
 Compares object to another object for equality. More...
 
virtual ErrCode INTERFACE_FUNC toString (CharPtr *str)=0
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from IUnknown
virtual ErrCode INTERFACE_FUNC queryInterface (const IntfID &intfID, void **obj)=0
 Returns another interface which is supported by the object and increments the reference count. More...
 
virtual int INTERFACE_FUNC addRef ()=0
 Increments the reference count for an interface on an object. More...
 
virtual int INTERFACE_FUNC releaseRef ()=0
 Decrements the reference count for an interface on an object. More...
 

Member Function Documentation

◆ addComponent()

virtual ErrCode INTERFACE_FUNC addComponent ( IString name,
ILoggerComponent **  component 
)
pure virtual

Creates a component with a given name and adds it to the Logger object.

Parameters
nameThe component's name.
[out]componentAdded component.
Return values
OPENDAQ_ERR_INVALIDPARAMETERif name is empty string.

◆ flushOnLevel()

virtual ErrCode INTERFACE_FUNC flushOnLevel ( LogLevel  level)
pure virtual

Sets the minimum severity level of messages to be automatically flushed by components of Logger object.

Parameters
levelThe log severity level.

◆ getComponent()

virtual ErrCode INTERFACE_FUNC getComponent ( IString name,
ILoggerComponent **  component 
)
pure virtual

Gets an added component by name.

Parameters
nameThe component's name.
[out]componentThe logger component with the name equal to name.
Return values
OPENDAQ_ERR_NOTFOUNDif a component with the specified name was not added.

◆ getComponents()

virtual ErrCode INTERFACE_FUNC getComponents ( IList **  components)
pure virtual

Gets a list of added components.

Parameters
[out]componentsThe list of added components.

◆ getLevel()

virtual ErrCode INTERFACE_FUNC getLevel ( LogLevel level)
pure virtual

Gets the default log severity level.

Parameters
[out]levelThe log severity level.

◆ getOrAddComponent()

virtual ErrCode INTERFACE_FUNC getOrAddComponent ( IString name,
ILoggerComponent **  component 
)
pure virtual

Gets an added component by name or creates a new one with a given name and adds it to the Logger object.

Parameters
nameThe component's name.
[out]componentThe logger component with the name equal to name.
Return values
OPENDAQ_ERR_INVALIDPARAMETERif name is empty string.

◆ removeComponent()

virtual ErrCode INTERFACE_FUNC removeComponent ( IString name)
pure virtual

Removes the component with a given name from the Logger object.

Parameters
nameThe component's name.
Return values
OPENDAQ_ERR_NOTFOUNDif a component with the specified name was not added.

◆ setLevel()

virtual ErrCode INTERFACE_FUNC setLevel ( LogLevel  level)
pure virtual

Sets the default log severity level.

Parameters
levelThe log severity level.