ifw-fgf 1.0.0-pre1
Loading...
Searching...
No Matches
logger.hpp
Go to the documentation of this file.
1
7#ifndef FGF_COM_LOGGER_HPP_H_
8#define FGF_COM_LOGGER_HPP_H_
9
10#include <fmt/format.h>
11
12#include <log4cplus/configurator.h>
13#include <log4cplus/logger.h>
14#include <log4cplus/loggingmacros.h>
15#include <log4cplus/helpers/stringhelper.h>
16
17#if __has_include(<open62541.h>)
18#include <open62541.h>
19#else
20#include <open62541/server.h>
21#include <open62541/plugin/log_stdout.h>
22#endif
23
24#include <ifw/fnd/defs/dataType.hpp>
25
26
27namespace ifw::fgf::common {
28
30 const std::string& LogPropertiesName(const std::string& log_properties = "");
31
33 const std::string& AppLogName(const std::string& _fgf_logger_name = "");
34
36 void ConfigureLogging();
37
39 log4cplus::Logger& GetRootLogger();
40
42 log4cplus::Logger& GetRootLogger();
43
45 log4cplus::Logger& GetAppLogger();
46
47 std::string FindFile(const std::string& resource_filename);
48
49 void CustomOpen62541Log(void* log_context,
50 UA_LogLevel level,
51 UA_LogCategory category,
52 const char* msg,
53 va_list args);
54 // {
55
56 // static log4cplus::Logger s_logger =
57 // log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("open62541"));
58
59 // char buffer[1024] = {};
60 // auto buffer_size = sizeof(buffer);
61 // auto ret_val = vsnprintf(buffer, buffer_size, msg, args);
62 // if (ret_val < 0) {
63 // std::cerr << "Logging message to big for the allocated buffer\n";
64 // return;
65 // }
66 // if (level == UA_LOGLEVEL_TRACE) {
67 // LOG4CPLUS_TRACE(s_logger, buffer);
68 // } else if (level == UA_LOGLEVEL_DEBUG) {
69 // LOG4CPLUS_DEBUG(s_logger, buffer);
70 // } else if (level == UA_LOGLEVEL_INFO) {
71 // LOG4CPLUS_INFO(s_logger, buffer);
72 // } else if (level == UA_LOGLEVEL_WARNING) {
73 // LOG4CPLUS_WARN(s_logger, buffer);
74 // } else if (level == UA_LOGLEVEL_ERROR) {
75 // LOG4CPLUS_ERROR(s_logger, buffer);
76 // } else if (level == UA_LOGLEVEL_FATAL) {
77 // LOG4CPLUS_FATAL(s_logger, buffer);
78 // }
79 // }
80
81
82#if ((UA_OPEN62541_VER_MAJOR * 100 + UA_OPEN62541_VER_MINOR) * 100 + UA_OPEN62541_VER_PATCH) >= 10400
83 static void CustomOpen62541LogClear(UA_Logger *log_context) {}
84 [[deprecated("use CustomOpen62541LogClear(UA_Logger*)")]]
85#endif
86 static void CustomOpen62541LogClear(void* log_context) __attribute__((unused));
87 static void CustomOpen62541LogClear(void* log_context) {}
88
89 [[maybe_unused]] static UA_Logger s_custom_logger =
90 { CustomOpen62541Log, nullptr, CustomOpen62541LogClear };
92
93}
94
95#endif // #ifndef FGF_COM_LOGGER_HPP_H_
96
Frame Grabber Camera Base Class definitions.
Definition binarySemaphore.hpp:43
void ConfigureLogging()
Configure log4cplus.
Definition logger.cpp:63
void CustomOpen62541Log(void *log_context, UA_LogLevel level, UA_LogCategory category, const char *msg, va_list args)
Definition logger.cpp:32
log4cplus::Logger & GetRootLogger()
Return reference to root logger.
Definition logger.cpp:79
const std::string & LogPropertiesName(const std::string &log_properties="")
Set the name of the log properties (default: "config/ifw/fgf/common/log.properties").
Definition logger.cpp:16
std::string FindFile(const std::string &resource_filename)
Definition logger.cpp:104
const std::string & AppLogName(const std::string &_fgf_logger_name="")
Set the name of the logger for this app (default: "fgf-app").
Definition logger.cpp:24
log4cplus::Logger & GetAppLogger()
Return reference to application logger.
Definition logger.cpp:88