NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
logger.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <string_view>
11
19
20#ifdef NNL_ENABLE_LOGGING
21#include "NNL/common/src_info.hpp"
22#define NNL_LOG_WARN(msg) \
23 do { \
24 nnl::Log(NNL_SRCTAG(msg), nnl::LogLevel::kWarn); \
25 } while (false)
26#define NNL_LOG_ERROR(msg) \
27 do { \
28 nnl::Log(NNL_SRCTAG(msg), nnl::LogLevel::kError); \
29 } while (false)
30#else
31#define NNL_LOG_WARN(msg) \
32 do { \
33 } while (false)
34#define NNL_LOG_ERROR(msg) \
35 do { \
36 } while (false)
37#endif
39
40namespace nnl {
46
50enum class LogLevel {
65};
66
74using LogFun = void (*)(std::string_view msg, LogLevel log_level);
75
88void SetGlobalLogCB(LogFun callback) noexcept;
89
90void Log(std::string_view msg, LogLevel log_lvl);
91
93} // namespace nnl
void(*)(std::string_view msg, LogLevel log_level) LogFun
Type definition for a logging function.
Definition logger.hpp:74
void SetGlobalLogCB(LogFun callback) noexcept
Sets the logging callback function.
LogLevel
Enum class representing log levels.
Definition logger.hpp:50
@ kWarn
Indicates warning conditions.
Definition logger.hpp:64
@ kError
Indicates error conditions.
Definition logger.hpp:57
Definition exception.hpp:56