S2OPC OPCUA Toolkit
sopc_log_manager.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
26 #ifndef SOPC_LOG_MANAGER_H_
27 #define SOPC_LOG_MANAGER_H_
28 
29 #include <stdarg.h>
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 #include "sopc_circular_log_file.h"
34 
36 
37 typedef enum
38 {
44 
57 typedef void SOPC_Log_UserDoLog(const char* timestampUtc,
58  const char* category,
59  const SOPC_Log_Level level,
60  const char* const line);
61 
66 {
67  const char* logDirPath;
68  uint32_t logMaxBytes;
69  uint16_t logMaxFiles;
71 
76 {
79 
83 typedef enum SOPC_Log_System
84 {
89 
94 {
98 
103 {
108 
119 
130 
142 
143 /*
144  * \brief Defines the active log level for the given log instance (default: ERROR):
145  * - ERROR: display only ERROR level
146  * - WARNING: display ERROR + WARNING levels
147  * - INFO: display ERROR + WARNING + INFO levels
148  * - DEBUG: display ERROR + WARNING + INFO + DEBUG levels
149  *
150  * \param pLogInst An existing log instance
151  * \param level The level to be activated for the log instance
152  */
154 
163 
170 bool SOPC_Log_SetConsoleOutput(SOPC_Log_Instance* pLogInst, bool activate);
171 
179 
187 void SOPC_Log_Trace(SOPC_Log_Instance* pLogInst, SOPC_Log_Level level, const char* format, ...);
188 
197 void SOPC_Log_VTrace(SOPC_Log_Instance* pLogInst, SOPC_Log_Level level, const char* format, va_list args);
198 
205 
206 #endif /* SOPC_LOG_MANAGER_H_ */
SOPC_LogSystem_File_Configuration
struct SOPC_LogSystem_File_Configuration SOPC_LogSystem_File_Configuration
structure containing the file log configuration
SOPC_Log_SystemConfiguration::fileSystemLogConfig
SOPC_LogSystem_File_Configuration fileSystemLogConfig
Definition: sopc_log_manager.h:95
SOPC_Log_CreateInstanceAssociation
SOPC_Log_Instance * SOPC_Log_CreateInstanceAssociation(SOPC_Log_Instance *pLogInst, const char *category)
Creates a new log instance using the same log file than existing log instance and prints the starting...
SOPC_LogSystem_File_Configuration::logDirPath
const char * logDirPath
Definition: sopc_log_manager.h:67
sopc_circular_log_file.h
SOPC_Log_Trace
void SOPC_Log_Trace(SOPC_Log_Instance *pLogInst, SOPC_Log_Level level, const char *format,...)
Logs a trace with the given level.
SOPC_Log_GetLogLevel
SOPC_Log_Level SOPC_Log_GetLogLevel(SOPC_Log_Instance *pLogInst)
getter for the log level of an instance
SOPC_Log_UserDoLog
void SOPC_Log_UserDoLog(const char *timestampUtc, const char *category, const SOPC_Log_Level level, const char *const line)
Log event callback.
Definition: sopc_log_manager.h:57
SOPC_Log_Configuration
struct SOPC_Log_Configuration SOPC_Log_Configuration
Defines logging configuration.
SOPC_Log_System
SOPC_Log_System
log system discriminant
Definition: sopc_log_manager.h:84
SOPC_Log_CreateFileInstance
SOPC_Log_Instance * SOPC_Log_CreateFileInstance(const SOPC_CircularLogFile_Configuration *pConf, const char *category)
Creates a new log file and log instance and prints the starting timestamp.
SOPC_Log_Level
SOPC_Log_Level
Definition: sopc_log_manager.h:38
SOPC_Log_Configuration
Defines logging configuration.
Definition: sopc_log_manager.h:103
SOPC_Log_GetCurrentFilename
char * SOPC_Log_GetCurrentFilename(const SOPC_Log_Instance *pLogInst)
Get the name of the current log file.
SOPC_LOG_LEVEL_INFO
@ SOPC_LOG_LEVEL_INFO
Definition: sopc_log_manager.h:41
SOPC_LogSystem_File_Configuration
structure containing the file log configuration
Definition: sopc_log_manager.h:66
SOPC_LOG_LEVEL_DEBUG
@ SOPC_LOG_LEVEL_DEBUG
Definition: sopc_log_manager.h:42
SOPC_Log_ClearInstance
void SOPC_Log_ClearInstance(SOPC_Log_Instance **ppLogInst)
Stops allowing to log traces in the given log instance. Log file is closed when last log instance is ...
SOPC_LogSystem_User_Configuration::doLog
SOPC_Log_UserDoLog * doLog
Definition: sopc_log_manager.h:77
SOPC_Log_Level
SOPC_Log_Level
Definition: libs2opc_client.h:79
SOPC_LogSystem_File_Configuration::logMaxFiles
uint16_t logMaxFiles
Definition: sopc_log_manager.h:69
SOPC_Log_Instance
struct SOPC_Log_Instance SOPC_Log_Instance
Definition: sopc_log_manager.h:35
SOPC_LOG_SYSTEM_FILE
@ SOPC_LOG_SYSTEM_FILE
Definition: sopc_log_manager.h:85
SOPC_LogSystem_File_Configuration::logMaxBytes
uint32_t logMaxBytes
Definition: sopc_log_manager.h:68
SOPC_LOG_LEVEL_WARNING
@ SOPC_LOG_LEVEL_WARNING
Definition: sopc_log_manager.h:40
SOPC_Log_SetLogLevel
bool SOPC_Log_SetLogLevel(SOPC_Log_Instance *pLogInst, SOPC_Log_Level level)
SOPC_Log_Configuration::logSystem
SOPC_Log_System logSystem
Definition: sopc_log_manager.h:105
SOPC_Log_Configuration::logLevel
SOPC_Log_Level logLevel
Definition: sopc_log_manager.h:104
SOPC_Log_Configuration::logSysConfig
SOPC_Log_SystemConfiguration logSysConfig
Definition: sopc_log_manager.h:106
SOPC_Log_SystemConfiguration
Provides possible logging configurations.
Definition: sopc_log_manager.h:94
SOPC_Log_VTrace
void SOPC_Log_VTrace(SOPC_Log_Instance *pLogInst, SOPC_Log_Level level, const char *format, va_list args)
Logs a trace with the given level.
SOPC_LOG_SYSTEM_NO_LOG
@ SOPC_LOG_SYSTEM_NO_LOG
Definition: sopc_log_manager.h:87
SOPC_LogSystem_User_Configuration
structure containing the user system log configuration
Definition: sopc_log_manager.h:76
SOPC_Log_SystemConfiguration::userSystemLogConfig
SOPC_LogSystem_User_Configuration userSystemLogConfig
Definition: sopc_log_manager.h:96
SOPC_Log_CreateUserInstance
SOPC_Log_Instance * SOPC_Log_CreateUserInstance(const char *category, SOPC_Log_UserDoLog *logCallback)
Creates a new log instance for user mode.
SOPC_LOG_LEVEL_ERROR
@ SOPC_LOG_LEVEL_ERROR
Definition: sopc_log_manager.h:39
SOPC_LogSystem_User_Configuration
struct SOPC_LogSystem_User_Configuration SOPC_LogSystem_User_Configuration
structure containing the user system log configuration
SOPC_CircularLogFile_Configuration
structure containing the file system log configuration
Definition: sopc_circular_log_file.h:39
SOPC_LOG_SYSTEM_USER
@ SOPC_LOG_SYSTEM_USER
Definition: sopc_log_manager.h:86
SOPC_Log_SystemConfiguration
union SOPC_Log_SystemConfiguration SOPC_Log_SystemConfiguration
Provides possible logging configurations.
SOPC_Log_SetConsoleOutput
bool SOPC_Log_SetConsoleOutput(SOPC_Log_Instance *pLogInst, bool activate)
Activates the console output for logged traces (same active level as log file)