OpcUaCanOpen
CANopen OPC-UA server
Log Namespace Reference

Typedefs

typedef size_t LogComponentHandle
 

Enumerations

enum  LOG_LEVEL {
  TRC = 0, DBG, INF, WRN,
  ERR
}
 

Functions

SHARED_LIB_EXPORT_DEFN bool initializeLogging (const Log::LOG_LEVEL &nonComponentLogLevel=Log::INF)
 Initializers: Logging can only be initialized ONCE! To try and avoid thread contention. More...
 
SHARED_LIB_EXPORT_DEFN bool initializeDllLogging (LogItInstance *remoteLogInstance)
 initializer to be called when using LogIt inside a shared library. More...
 
SHARED_LIB_EXPORT_DEFN LogComponentHandle registerLoggingComponent (const std::string &componentName, const Log::LOG_LEVEL &nonComponentLogLevel=Log::INF)
 register a user defined logging component. More...
 
SHARED_LIB_EXPORT_DEFN bool isLoggable (const Log::LOG_LEVEL &level)
 log check: should message be logged? More...
 
SHARED_LIB_EXPORT_DEFN bool isLoggable (const Log::LOG_LEVEL &level, const LogComponentHandle &componentHandle)
 
SHARED_LIB_EXPORT_DEFN bool isLoggable (const Log::LOG_LEVEL &level, const std::string &componentName)
 
SHARED_LIB_EXPORT_DEFN void setNonComponentLogLevel (const Log::LOG_LEVEL &level)
 Get/Set the log threshold for all LOG messages without a component specified, i.e. More...
 
SHARED_LIB_EXPORT_DEFN Log::LOG_LEVEL getNonComponentLogLevel (void)
 
SHARED_LIB_EXPORT_DEFN const std::map< Log::LogComponentHandle, std::string > getComponentLogsList ()
 Get/Set the log threshold for all LOG messages where a component is specified, i.e. More...
 
SHARED_LIB_EXPORT_DEFN bool setComponentLogLevel (const LogComponentHandle &componentHandle, const LOG_LEVEL &level)
 
SHARED_LIB_EXPORT_DEFN bool getComponentLogLevel (const LogComponentHandle &componentHandle, LOG_LEVEL &level)
 
SHARED_LIB_EXPORT_DEFN std::string getComponentName (const LogComponentHandle &componentHandle)
 Finds the user defined string (specified in the registerLoggingComponent call) for a given componentHandle. More...
 
SHARED_LIB_EXPORT_DEFN LogComponentHandle getComponentHandle (const std::string componentName)
 Finds the component handle for a given component name. More...
 
std::string logLevelToString (const LOG_LEVEL &level)
 
bool logLevelFromString (const std::string &s, LOG_LEVEL &out)
 

Variables

const size_t g_sMaxComponentIdCount = 512
 
const LogComponentHandle INVALID_HANDLE = 999999999
 

Typedef Documentation

◆ LogComponentHandle

typedef size_t Log::LogComponentHandle

Definition at line 35 of file LogItStaticDefinitions.h.

Enumeration Type Documentation

◆ LOG_LEVEL

Enumerator
TRC 
DBG 
INF 
WRN 
ERR 

Definition at line 29 of file LogLevels.h.

Function Documentation

◆ getComponentHandle()

Log::LogComponentHandle Log::getComponentHandle ( const std::string  componentName)

Finds the component handle for a given component name.

If there is no component registered with that name, returns Log::INVALID_HANDLE, otherwise returns the component handle.

Definition at line 196 of file LogIt.cpp.

◆ getComponentLogLevel()

bool Log::getComponentLogLevel ( const LogComponentHandle componentHandle,
LOG_LEVEL level 
)

Definition at line 175 of file LogIt.cpp.

◆ getComponentLogsList()

const std::map< Log::LogComponentHandle, string > Log::getComponentLogsList ( )

Get/Set the log threshold for all LOG messages where a component is specified, i.e.

calls such as LOG(Log::INF, USER_DEFINED_COMPONENT_HANDLE_1) << "log message tagged with component id"

Note getComponentLogLevel returns false if componentHandle not registered.

Definition at line 156 of file LogIt.cpp.

◆ getComponentName()

string Log::getComponentName ( const LogComponentHandle componentHandle)

Finds the user defined string (specified in the registerLoggingComponent call) for a given componentHandle.

If there is no component registered with that handle, returns "UNKNOWN", otherwise returns the component name.

Definition at line 186 of file LogIt.cpp.

◆ getNonComponentLogLevel()

Log::LOG_LEVEL Log::getNonComponentLogLevel ( void  )

Definition at line 151 of file LogIt.cpp.

◆ initializeDllLogging()

bool Log::initializeDllLogging ( LogItInstance remoteLogInstance)

initializer to be called when using LogIt inside a shared library.

The remoteLogInstance ptr should be supplied to the shared library from the main executable (note that this will probably require that the shared library API supports passing this ptr before the shared library can initialize the logger and start logging).

The ptr (in the main executable, to pass to the DLL) is available from LogItInstance::getInstance() after the exe calls LogIt::initialiseLogging().

Definition at line 93 of file LogIt.cpp.

◆ initializeLogging()

bool Log::initializeLogging ( const Log::LOG_LEVEL nonComponentLogLevel = Log::INF)

Initializers: Logging can only be initialized ONCE! To try and avoid thread contention.

Note: although logging is initialized once, logging thresholds (for non-component and component verbosity) can be set at any time (by any thread). Simple initializer, without component specific logging. Only LOG(LOG_LEVEL) invocations will be considered for logging, subject to logging verbosity threshold.

Definition at line 84 of file LogIt.cpp.

◆ isLoggable() [1/3]

bool Log::isLoggable ( const Log::LOG_LEVEL level)

log check: should message be logged?

no component (single-arg : level) and component specific (double-arg : level + (handle or name))

Definition at line 116 of file LogIt.cpp.

◆ isLoggable() [2/3]

bool Log::isLoggable ( const Log::LOG_LEVEL level,
const LogComponentHandle componentHandle 
)

Definition at line 122 of file LogIt.cpp.

◆ isLoggable() [3/3]

bool Log::isLoggable ( const Log::LOG_LEVEL level,
const std::string &  componentName 
)

Definition at line 132 of file LogIt.cpp.

◆ logLevelFromString()

bool Log::logLevelFromString ( const std::string &  s,
LOG_LEVEL out 
)

Definition at line 40 of file LogLevels.cpp.

◆ logLevelToString()

std::string Log::logLevelToString ( const LOG_LEVEL level)

Definition at line 27 of file LogLevels.cpp.

◆ registerLoggingComponent()

SHARED_LIB_EXPORT_DEFN LogComponentHandle Log::registerLoggingComponent ( const std::string &  componentName,
const Log::LOG_LEVEL nonComponentLogLevel = Log::INF 
)

register a user defined logging component.

LOG(LOG_LEVEL) invocations will be considered for logging and LOG(LOG_LEVEL, USER_COMPONENT) i.e. calls for registered components, will be considered for logging, subject to threshold.

RETURNS: the logging component handle, or, in case of error, Log::INVALID_HANDLE

◆ setComponentLogLevel()

bool Log::setComponentLogLevel ( const LogComponentHandle componentHandle,
const LOG_LEVEL level 
)

Definition at line 164 of file LogIt.cpp.

◆ setNonComponentLogLevel()

void Log::setNonComponentLogLevel ( const Log::LOG_LEVEL level)

Get/Set the log threshold for all LOG messages without a component specified, i.e.

calls such as LOG(Log::INF) << "general log message"

Definition at line 142 of file LogIt.cpp.

Variable Documentation

◆ g_sMaxComponentIdCount

const size_t Log::g_sMaxComponentIdCount = 512

Definition at line 37 of file LogItStaticDefinitions.h.

◆ INVALID_HANDLE

const LogComponentHandle Log::INVALID_HANDLE = 999999999

Definition at line 38 of file LogItStaticDefinitions.h.