open62541pp 0.19.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
log_default.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <utility> // move
5
7
8namespace opcua {
9
10/// Log function.
11using LogFunction = std::function<void(LogLevel, LogCategory, std::string_view msg)>;
12
13/**
14 * Logger class that wraps a `LogFunction`.
15 */
16class LoggerDefault : public LoggerBase {
17public:
19 : func_{std::move(func)} {}
20
21 void log(LogLevel level, LogCategory category, std::string_view msg) override {
22 if (func_) {
23 func_(level, category, msg);
24 }
25 }
26
27private:
28 LogFunction func_;
29};
30
31} // namespace opcua
Logger base class.
Definition log.hpp:42
Logger class that wraps a LogFunction.
void log(LogLevel level, LogCategory category, std::string_view msg) override
LoggerDefault(LogFunction func)
static UA_LogCategory category
static UA_LogCategory const char * msg
LogLevel
Log level.
Definition log.hpp:14
LogCategory
Log category.
Definition log.hpp:27
std::function< void(LogLevel, LogCategory, std::string_view msg)> LogFunction
Log function.