OpcUaCanOpen
CANopen OPC-UA server
LogIt.h File Reference
#include <stdint.h>
#include <iostream>
#include <list>
#include "LogItStaticDefinitions.h"
#include "LogRecord.h"
#include "LogLevels.h"
#include "LogItInstance.h"

Go to the source code of this file.

Namespaces

 Log
 

Macros

#define LOG_WITHOUT_COMPONENT(level)
 
#define LOG_WITH_COMPONENT(level, component)
 
#define GET_LOG_MACRO(_1, _2, LOG_MACRO_NAME, ...)   LOG_MACRO_NAME
 The one and only LOG macro - application code should log using this macro. More...
 
#define LOG(...)   GET_LOG_MACRO(__VA_ARGS__, LOG_WITH_COMPONENT, LOG_WITHOUT_COMPONENT)(__VA_ARGS__)
 

Functions

SHARED_LIB_EXPORT_DEFN bool Log::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 Log::initializeDllLogging (LogItInstance *remoteLogInstance)
 initializer to be called when using LogIt inside a shared library. More...
 
SHARED_LIB_EXPORT_DEFN LogComponentHandle Log::registerLoggingComponent (const std::string &componentName, const Log::LOG_LEVEL &nonComponentLogLevel=Log::INF)
 register a user defined logging component. More...
 
SHARED_LIB_EXPORT_DEFN bool Log::isLoggable (const Log::LOG_LEVEL &level)
 log check: should message be logged? More...
 
SHARED_LIB_EXPORT_DEFN bool Log::isLoggable (const Log::LOG_LEVEL &level, const LogComponentHandle &componentHandle)
 
SHARED_LIB_EXPORT_DEFN bool Log::isLoggable (const Log::LOG_LEVEL &level, const std::string &componentName)
 
SHARED_LIB_EXPORT_DEFN void Log::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 Log::getNonComponentLogLevel (void)
 
SHARED_LIB_EXPORT_DEFN const std::map< Log::LogComponentHandle, std::string > Log::getComponentLogsList ()
 Get/Set the log threshold for all LOG messages where a component is specified, i.e. More...
 
SHARED_LIB_EXPORT_DEFN bool Log::setComponentLogLevel (const LogComponentHandle &componentHandle, const LOG_LEVEL &level)
 
SHARED_LIB_EXPORT_DEFN bool Log::getComponentLogLevel (const LogComponentHandle &componentHandle, LOG_LEVEL &level)
 
SHARED_LIB_EXPORT_DEFN std::string Log::getComponentName (const LogComponentHandle &componentHandle)
 Finds the user defined string (specified in the registerLoggingComponent call) for a given componentHandle. More...
 
SHARED_LIB_EXPORT_DEFN LogComponentHandle Log::getComponentHandle (const std::string componentName)
 Finds the component handle for a given component name. More...
 

Macro Definition Documentation

◆ GET_LOG_MACRO

#define GET_LOG_MACRO (   _1,
  _2,
  LOG_MACRO_NAME,
  ... 
)    LOG_MACRO_NAME

The one and only LOG macro - application code should log using this macro.

Invocations resolve to either

Definition at line 52 of file LogIt.h.

◆ LOG

#define LOG (   ...)    GET_LOG_MACRO(__VA_ARGS__, LOG_WITH_COMPONENT, LOG_WITHOUT_COMPONENT)(__VA_ARGS__)

Definition at line 53 of file LogIt.h.

◆ LOG_WITH_COMPONENT

#define LOG_WITH_COMPONENT (   level,
  component 
)
Value:
if( !Log::isLoggable(level, component) ) (void)0; \
else LogRecord(__FILE__, __LINE__, level, component).getStream()

Definition at line 39 of file LogIt.h.

◆ LOG_WITHOUT_COMPONENT

#define LOG_WITHOUT_COMPONENT (   level)
Value:
if( !Log::isLoggable(level) ) (void)0; \
else LogRecord(__FILE__, __LINE__, level).getStream()

Definition at line 34 of file LogIt.h.