open62541pp 0.17.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
13using Logger [[deprecated("use alias LogFunction instead")]] = LogFunction;
14
15/**
16 * Logger class that wraps a `LogFunction`.
17 */
18class LoggerDefault : public LoggerBase {
19public:
21 : func_(std::move(func)) {}
22
23 void log(LogLevel level, LogCategory category, std::string_view msg) override {
24 if (func_) {
25 func_(level, category, msg);
26 }
27 }
28
29private:
30 LogFunction func_;
31};
32
33} // 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.