S2OPC OPCUA Toolkit
sopc_logger.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_LOGGER_H_
27 #define SOPC_LOGGER_H_
28 
29 #include <stdbool.h>
30 #include <stdint.h>
31 
32 #include "sopc_log_manager.h"
33 
34 #ifdef __GNUC__
35 #define ATTR_FORMAT(archetype, string_index, first) __attribute__((format(archetype, string_index, first)))
36 #else
37 #define ATTR_FORMAT(archetype, string_index, first)
38 #endif
39 
40 #define LOGGER_FUNC_FORMAT_ENUM ATTR_FORMAT(printf, 2, 3)
41 #define LOGGER_FUNC_FORMAT ATTR_FORMAT(printf, 1, 2)
42 
46 typedef enum SOPC_Log_Module
47 {
52 
59 bool SOPC_Logger_Initialize(const SOPC_Log_Configuration* const logConfiguration);
60 
69 
80 
87 
93 void SOPC_Logger_SetConsoleOutput(bool activate);
94 
101 void SOPC_Logger_TraceError(SOPC_Log_Module logModule, const char* format, ...) LOGGER_FUNC_FORMAT_ENUM;
102 
109 void SOPC_Logger_TraceWarning(SOPC_Log_Module logModule, const char* format, ...) LOGGER_FUNC_FORMAT_ENUM;
110 
117 void SOPC_Logger_TraceInfo(SOPC_Log_Module logModule, const char* format, ...) LOGGER_FUNC_FORMAT_ENUM;
118 
119 /*
120  * \brief Log a trace with the debug level
121  *
122  * \param logModule The log module
123  * \param format String specifying how subsequent arguments are converted for output
124  */
125 void SOPC_Logger_TraceDebug(SOPC_Log_Module logModule, const char* format, ...) LOGGER_FUNC_FORMAT_ENUM;
126 
133 
140 
146 void SOPC_Logger_TraceOpcUaAudit(const char* format, ...) LOGGER_FUNC_FORMAT;
147 
154 
158 void SOPC_Logger_Clear(void);
159 
160 #endif /* SOPC_LOGGER_H_ */
LOGGER_FUNC_FORMAT_ENUM
#define LOGGER_FUNC_FORMAT_ENUM
Definition: sopc_logger.h:40
SOPC_Logger_SetConsoleOutput
void SOPC_Logger_SetConsoleOutput(bool activate)
Activates the console output for logged traces (same active level as log file)
SOPC_LOG_MODULE_COMMON
@ SOPC_LOG_MODULE_COMMON
Definition: sopc_logger.h:48
SOPC_Logger_TraceDebug
void SOPC_Logger_TraceDebug(SOPC_Log_Module logModule, const char *format,...) LOGGER_FUNC_FORMAT_ENUM
SOPC_Logger_TraceError
void SOPC_Logger_TraceError(SOPC_Log_Module logModule, const char *format,...) LOGGER_FUNC_FORMAT_ENUM
Log a trace with the error level.
SOPC_Log_Configuration
Defines logging configuration.
Definition: sopc_log_manager.h:103
SOPC_Logger_SetTraceLogLevel
void SOPC_Logger_SetTraceLogLevel(SOPC_Log_Level level)
Defines the active log level for the given log instance (default: ERROR):
SOPC_Log_Level
SOPC_Log_Level
Definition: libs2opc_client.h:79
SOPC_Log_Instance
struct SOPC_Log_Instance SOPC_Log_Instance
Definition: sopc_log_manager.h:35
sopc_log_manager.h
Provide circular logging.
SOPC_Logger_TraceWarning
void SOPC_Logger_TraceWarning(SOPC_Log_Module logModule, const char *format,...) LOGGER_FUNC_FORMAT_ENUM
Log a trace with the warning level.
SOPC_Logger_Clear
void SOPC_Logger_Clear(void)
Clears the logger and close the current log files.
SOPC_Logger_TraceOpcUaAudit
void SOPC_Logger_TraceOpcUaAudit(const char *format,...) LOGGER_FUNC_FORMAT
Log a trace for the OPC UA audit log.
LOGGER_FUNC_FORMAT
#define LOGGER_FUNC_FORMAT
Definition: sopc_logger.h:41
SOPC_Logger_TraceSecurityAudit
void SOPC_Logger_TraceSecurityAudit(const char *format,...) LOGGER_FUNC_FORMAT
Log a trace for the security audit log.
SOPC_Logger_TraceOpcUaAuditWarning
void SOPC_Logger_TraceOpcUaAuditWarning(const char *format,...) LOGGER_FUNC_FORMAT
Log a warning trace for the OPC UA audit log.
SOPC_Logger_TraceSecurityAuditWarning
void SOPC_Logger_TraceSecurityAuditWarning(const char *format,...) LOGGER_FUNC_FORMAT
Log a warning trace for the security audit log.
SOPC_Logger_TraceInfo
void SOPC_Logger_TraceInfo(SOPC_Log_Module logModule, const char *format,...) LOGGER_FUNC_FORMAT_ENUM
Log a trace with the info level.
SOPC_Logger_Initialize
bool SOPC_Logger_Initialize(const SOPC_Log_Configuration *const logConfiguration)
Initializes the logger system.
SOPC_Logger_AddUserInstance
SOPC_Log_Instance * SOPC_Logger_AddUserInstance(const char *category)
Add a user instance in the existing Toolkit log. The new created instance is managed by SOPC_Logger a...
SOPC_LOG_MODULE_CLIENTSERVER
@ SOPC_LOG_MODULE_CLIENTSERVER
Definition: sopc_logger.h:49
SOPC_Log_Module
SOPC_Log_Module
enumerate to define log modules
Definition: sopc_logger.h:47
SOPC_Logger_GetTraceLogLevel
SOPC_Log_Level SOPC_Logger_GetTraceLogLevel(void)
getter for the log level
SOPC_LOG_MODULE_PUBSUB
@ SOPC_LOG_MODULE_PUBSUB
Definition: sopc_logger.h:50