Mantis App v0.1.13
Loading...
Searching...
No Matches
logging.h
Go to the documentation of this file.
1
8#ifndef MANTIS_LOGGER_H
9#define MANTIS_LOGGER_H
10
11#include <../../3rdParty/json/single_include/nlohmann/json.hpp>
12#include <../../3rdParty/spdlog/include/spdlog/spdlog.h>
13#include <../../3rdParty/spdlog/include/spdlog/sinks/basic_file_sink.h>
14
15namespace mantis
16{
17 using json = nlohmann::json;
18
22 typedef enum class LogLevel : uint8_t
23 {
24 TRACE = 0,
25 DEBUG,
26 INFO,
27 WARN,
30
36 {
37 public:
38 LoggingUnit() = default;
39 ~LoggingUnit() = default;
40
41 static void init();
42 static void close();
43
44 static void setLogLevel(const LogLevel& level = LogLevel::INFO);
45
46 template <typename... Args>
47 static void trace(fmt::format_string<Args...> msg, Args&&... args)
48 {
49 spdlog::trace(msg, std::forward<Args>(args)...);
50 }
51
52 template <typename... Args>
53 static void info(fmt::format_string<Args...> msg, Args&&... args)
54 {
55 spdlog::info(msg, std::forward<Args>(args)...);
56 }
57
58 template <typename... Args>
59 static void debug(fmt::format_string<Args...> msg, Args&&... args)
60 {
61 spdlog::debug(msg, std::forward<Args>(args)...);
62 }
63
64 template <typename... Args>
65 static void warn(fmt::format_string<Args...> msg, Args&&... args)
66 {
67 spdlog::warn(msg, std::forward<Args>(args)...);
68 }
69
70 template <typename... Args>
71 static void critical(fmt::format_string<Args...> msg, Args&&... args)
72 {
73 spdlog::critical(msg, std::forward<Args>(args)...);
74 }
75 };
76
78}
79
80#define TRACE_CLASS_METHOD() Log::trace("Enter > {} {}::{}()", __file__, __class_name__, __func__);
81#define TRACE_METHOD Log::trace("Enter > {} {}()", __file__, __func__);
82
83#endif //MANTIS_LOGGER_H
Definition logging.h:36
static void warn(fmt::format_string< Args... > msg, Args &&... args)
Definition logging.h:65
static void trace(fmt::format_string< Args... > msg, Args &&... args)
Definition logging.h:47
static void setLogLevel(const LogLevel &level=LogLevel::INFO)
Definition logging.cpp:15
static void critical(fmt::format_string< Args... > msg, Args &&... args)
Definition logging.h:71
static void init()
Definition logging.cpp:27
static void info(fmt::format_string< Args... > msg, Args &&... args)
Definition logging.h:53
~LoggingUnit()=default
static void close()
Definition logging.cpp:10
static void debug(fmt::format_string< Args... > msg, Args &&... args)
Definition logging.h:59
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:30
LogLevel
Definition logging.h:23
@ WARN
‍Info Logging Level
@ INFO
‍Debug Logging Level
@ CRITICAL
‍Warning Logging Level
@ DEBUG
‍Trace logging level