Webserv
Loading...
Searching...
No Matches
Logger.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <sstream>
5
6namespace utils {
7
20
21class Logger {
22public:
23 static void log(LogLevel, std::string const &);
24 static void setLevel(LogLevel);
25
26private:
28};
29
37#define LOG_MSG(level, msg) \
38 { \
39 std::ostringstream oss; \
40 oss << msg; \
41 utils::Logger::log(level, oss.str()); \
42 }
43
49#define LOG_TRACE(msg) LOG_MSG(utils::TRACE, msg)
50
56#define LOG_DEBUG(msg) LOG_MSG(utils::DEBUG, msg)
57
63#define LOG_INFO(msg) LOG_MSG(utils::INFO, msg)
64
70#define LOG_WARN(msg) LOG_MSG(utils::WARNING, msg)
71
77#define LOG_ERROR(msg) LOG_MSG(utils::ERROR, msg)
78
84#define LOG_FATAL(msg) LOG_MSG(utils::FATAL, msg)
85
86} // namespace utils
Definition Logger.hpp:21
static LogLevel threshold_
Definition Logger.hpp:27
static void setLevel(LogLevel)
Definition Logger.cpp:52
static void log(LogLevel, std::string const &)
Definition Logger.cpp:32
Definition utils.hpp:6
LogLevel
Defines the severity levels for log messages.
Definition Logger.hpp:12
@ TRACE
Fine-grained messages, typically for detailed debugging.
Definition Logger.hpp:13
@ DEBUG
Information useful for developers during debugging.
Definition Logger.hpp:14
@ INFO
Informational messages about application progress.
Definition Logger.hpp:15
@ ERROR
An error that occurred but the application can recover from.
Definition Logger.hpp:17
@ FATAL
A critical error that will likely lead to termination.
Definition Logger.hpp:18
@ WARNING
Indicates a potential issue that is not a critical error.
Definition Logger.hpp:16