S2OPC OPCUA Toolkit
Data Structures | Typedefs | Enumerations | Functions
sopc_log_manager.h File Reference

A log manager providing circular logging, multiple logging categories and levels with thread-safe accesses. More...

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  SOPC_LogSystem_File_Configuration
 structure containing the file system log configuration More...
 
struct  SOPC_LogSystem_User_Configuration
 structure containing the user system log configuration More...
 
union  SOPC_Log_SystemConfiguration
 Provides possible logging configurations. More...
 
struct  SOPC_Log_Configuration
 Defines logging configuration. More...
 

Typedefs

typedef struct SOPC_Log_Instance SOPC_Log_Instance
 
typedef void SOPC_Log_UserDoLog(const char *category, const char *const line)
 Log event callback. More...
 
typedef struct SOPC_LogSystem_File_Configuration SOPC_LogSystem_File_Configuration
 structure containing the file system log configuration More...
 
typedef struct SOPC_LogSystem_User_Configuration SOPC_LogSystem_User_Configuration
 structure containing the user system log configuration More...
 
typedef enum SOPC_Log_System SOPC_Log_System
 log system discriminant More...
 
typedef union SOPC_Log_SystemConfiguration SOPC_Log_SystemConfiguration
 Provides possible logging configurations. More...
 
typedef struct SOPC_Log_Configuration SOPC_Log_Configuration
 Defines logging configuration. More...
 

Enumerations

enum  SOPC_Log_Level {
  SOPC_LOG_LEVEL_ERROR = 0, SOPC_LOG_LEVEL_WARNING = 1, SOPC_LOG_LEVEL_INFO = 2, SOPC_LOG_LEVEL_DEBUG = 3,
  SOPC_LOG_LEVEL_ERROR = 0, SOPC_LOG_LEVEL_WARNING = 1, SOPC_LOG_LEVEL_INFO = 2, SOPC_LOG_LEVEL_DEBUG = 3
}
 
enum  SOPC_Log_System { SOPC_LOG_SYSTEM_FILE, SOPC_LOG_SYSTEM_USER, SOPC_LOG_SYSTEM_NO_LOG }
 log system discriminant More...
 

Functions

void SOPC_Log_Initialize (void)
 Initializes the logger manager: generate unique file name prefix for execution. This prefix is only relevant when the logging feature is set to default file logging. Only the first call is taken into account. Further call will be ignored until next call to :: SOPC_Log_Clear. More...
 
SOPC_Log_InstanceSOPC_Log_CreateFileInstance (const char *logDirPath, const char *logFileName, const char *category, uint32_t maxBytes, uint16_t maxFiles)
 Creates a new log file and log instance and prints the starting timestamp. More...
 
SOPC_Log_InstanceSOPC_Log_CreateUserInstance (const char *category, SOPC_Log_UserDoLog *logCallback)
 
SOPC_Log_InstanceSOPC_Log_CreateInstanceAssociation (SOPC_Log_Instance *pLogInst, const char *category)
 
bool SOPC_Log_SetLogLevel (SOPC_Log_Instance *pLogInst, SOPC_Log_Level level)
 
SOPC_Log_Level SOPC_Log_GetLogLevel (SOPC_Log_Instance *pLogInst)
 
bool SOPC_Log_SetConsoleOutput (SOPC_Log_Instance *pLogInst, bool activate)
 
char * SOPC_Log_GetFilePathPrefix (SOPC_Log_Instance *pLogInst)
 
void SOPC_Log_Trace (SOPC_Log_Instance *pLogInst, SOPC_Log_Level level, const char *format,...)
 
void SOPC_Log_VTrace (SOPC_Log_Instance *pLogInst, SOPC_Log_Level level, const char *format, va_list args)
 
void SOPC_Log_ClearInstance (SOPC_Log_Instance **ppLogInst)
 
void SOPC_Log_Clear (void)
 

Detailed Description

A log manager providing circular logging, multiple logging categories and levels with thread-safe accesses.

Typedef Documentation

◆ SOPC_Log_Instance

◆ SOPC_Log_UserDoLog

typedef void SOPC_Log_UserDoLog(const char *category, const char *const line)

Log event callback.

Parameters
[in]categoryString pointer containing the category. Can be NULL, when not related to any category,
[in]lineNon-null string pointer, containing the full log line, including NULL-terminating character but excluding any newline character, so that it can be specificly defined for each platform. The line has already been filtered (level) and formatted by logger core. In all cases, the line is truncated to SOPC_Log_UserMaxLogLen characters.

◆ SOPC_LogSystem_File_Configuration

structure containing the file system log configuration

◆ SOPC_LogSystem_User_Configuration

structure containing the user system log configuration

◆ SOPC_Log_System

log system discriminant

◆ SOPC_Log_SystemConfiguration

Provides possible logging configurations.

◆ SOPC_Log_Configuration

Defines logging configuration.

Enumeration Type Documentation

◆ SOPC_Log_Level

Enumerator
SOPC_LOG_LEVEL_ERROR 
SOPC_LOG_LEVEL_WARNING 
SOPC_LOG_LEVEL_INFO 
SOPC_LOG_LEVEL_DEBUG 
SOPC_LOG_LEVEL_ERROR 
SOPC_LOG_LEVEL_WARNING 
SOPC_LOG_LEVEL_INFO 
SOPC_LOG_LEVEL_DEBUG 

◆ SOPC_Log_System

log system discriminant

Enumerator
SOPC_LOG_SYSTEM_FILE 

file system logger

SOPC_LOG_SYSTEM_USER 

user-implemented system logger

SOPC_LOG_SYSTEM_NO_LOG 

no system logger

Function Documentation

◆ SOPC_Log_Initialize()

void SOPC_Log_Initialize ( void  )

Initializes the logger manager: generate unique file name prefix for execution. This prefix is only relevant when the logging feature is set to default file logging. Only the first call is taken into account. Further call will be ignored until next call to :: SOPC_Log_Clear.

◆ SOPC_Log_CreateFileInstance()

SOPC_Log_Instance* SOPC_Log_CreateFileInstance ( const char *  logDirPath,
const char *  logFileName,
const char *  category,
uint32_t  maxBytes,
uint16_t  maxFiles 
)

Creates a new log file and log instance and prints the starting timestamp.

Parameters
logDirPathAbsolute or relative path of the directory to be used for logs (shall exist and terminate with directory separator)
logFileNameThe file name to be used without extension. A prefix, an integer suffix and extension will be added automatically.
categoryA category name if the log file is used for several categories or NULL. Truncated if more than 9 characters.
maxBytesA maximum amount of bytes by log file before opening a new file incrementing the integer suffix. It is a best effort value (amount verified after each print).
maxFilesA maximum number of files to be used, when reached the older log file is overwritten (starting with *_00001.log)
Returns
The log instance to be used to add traces

◆ SOPC_Log_CreateUserInstance()

SOPC_Log_Instance* SOPC_Log_CreateUserInstance ( const char *  category,
SOPC_Log_UserDoLog logCallback 
)

◆ SOPC_Log_CreateInstanceAssociation()

SOPC_Log_Instance* SOPC_Log_CreateInstanceAssociation ( SOPC_Log_Instance pLogInst,
const char *  category 
)

◆ SOPC_Log_SetLogLevel()

bool SOPC_Log_SetLogLevel ( SOPC_Log_Instance pLogInst,
SOPC_Log_Level  level 
)

◆ SOPC_Log_GetLogLevel()

SOPC_Log_Level SOPC_Log_GetLogLevel ( SOPC_Log_Instance pLogInst)

◆ SOPC_Log_SetConsoleOutput()

bool SOPC_Log_SetConsoleOutput ( SOPC_Log_Instance pLogInst,
bool  activate 
)

◆ SOPC_Log_GetFilePathPrefix()

char* SOPC_Log_GetFilePathPrefix ( SOPC_Log_Instance pLogInst)

◆ SOPC_Log_Trace()

void SOPC_Log_Trace ( SOPC_Log_Instance pLogInst,
SOPC_Log_Level  level,
const char *  format,
  ... 
)

◆ SOPC_Log_VTrace()

void SOPC_Log_VTrace ( SOPC_Log_Instance pLogInst,
SOPC_Log_Level  level,
const char *  format,
va_list  args 
)

◆ SOPC_Log_ClearInstance()

void SOPC_Log_ClearInstance ( SOPC_Log_Instance **  ppLogInst)

◆ SOPC_Log_Clear()

void SOPC_Log_Clear ( void  )