Logger v1.0.0
Custom cli console for creating commands executable at runtime
Loading...
Searching...
No Matches
logger.hpp
1#ifndef LOGGER_HPP_
2#define LOGGER_HPP_
3#include <mutex>
4#include <string>
5
6namespace lg {
14inline class Log {
15public:
19 enum class LogLevel {
20 info = 0x01,
21 warning = 0x02,
22 error = 0x04,
23 debug = 0x08,
24 memory = 0x10
25 };
26
27private:
28 short _level = (short)LogLevel::info | (short)LogLevel::warning |
29 (short)LogLevel::error | (short)LogLevel::debug |
30 (short)LogLevel::memory;
31 static std::mutex _mutex;
32
33public:
44 void operator()(LogLevel level, std::string text);
45
55 void operator()(std::string text);
56
65 void SetLevel(short log_level);
66
67private:
68 static void Log_(std::string text, enum LogLevel level);
69
70 static std::string LogLevelToText_(enum LogLevel);
71} log;
72} // namespace lg
73
74#endif
Log manages logging with levels and timestamps.
Definition logger.hpp:14
LogLevel
Enum specifying the log level.
Definition logger.hpp:19
void SetLevel(short log_level)
Sets the levels that are supposed to be displayed.
Definition logger.cpp:18
void operator()(LogLevel level, std::string text)
Prints out a log with a set log level.
Definition logger.cpp:7