CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Logger.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Logger.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/06 12:42:32 by kamitsui #+# #+# */
9/* Updated: 2025/06/06 12:48:35 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
23#ifndef LOGGER_HPP
24#define LOGGER_HPP
25
26#include <iostream> // std::cout, std::cerr, std::endl
27#include <string>
28
37class Logger {
38 public:
47
48 Logger();
49 Logger(const Logger &other);
50 Logger &operator=(const Logger &other);
51 ~Logger();
52
53 static void log(LogLevel level, const std::string &message);
54
55 private:
56 // The private section can be used for internal implementation details.
57 // In this singleton-like design, no instance members are typically needed.
58};
59
67#ifdef DEBUG_MODE
68#define LOG_INFO(msg) Logger::log(Logger::LOG_INFO, msg)
69#else
70#define LOG_INFO(msg) \
71 do { \
72 } while (0)
73#endif
74
82#ifdef DEBUG_MODE
83#define LOG_WARNING(msg) Logger::log(Logger::LOG_WARNING, msg)
84#else
85#define LOG_WARNING(msg) \
86 do { \
87 } while (0)
88#endif
89
90#ifdef DEBUG_MODE
91#define LOG_ERROR(msg) Logger::log(Logger::LOG_ERROR, msg)
92#else
93#define LOG_ERROR(msg) \
94 do { \
95 } while (0)
96#endif
97
98#endif // LOGGER_HPP
The Logger class provides static methods for logging messages.
Definition Logger.hpp:37
static void log(LogLevel level, const std::string &message)
Logs a message with a specified log level to the console.
Definition Logger.cpp:66
Logger()
Default constructor for Logger.
Definition Logger.cpp:29
LogLevel
Defines the severity levels for log messages.
Definition Logger.hpp:42
@ LOG_INFO
An informational message.
Definition Logger.hpp:43
@ LOG_WARNING
A warning message, indicating a potential issue.
Definition Logger.hpp:44
@ LOG_ERROR
An error message, indicating a significant problem.
Definition Logger.hpp:45
~Logger()
Destructor for Logger.
Definition Logger.cpp:37
Logger & operator=(const Logger &other)
Copy assignment operator for Logger.
Definition Logger.cpp:52