diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/cpp/logger/logger.hh | |
add: graphs et rushs
Diffstat (limited to 'graphs/cpp/logger/logger.hh')
| -rw-r--r-- | graphs/cpp/logger/logger.hh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/graphs/cpp/logger/logger.hh b/graphs/cpp/logger/logger.hh new file mode 100644 index 0000000..4b3a43b --- /dev/null +++ b/graphs/cpp/logger/logger.hh @@ -0,0 +1,47 @@ +#pragma once +#include <fstream> +#include <string> + +namespace LogMe +{ + enum logging_level + { + DEBUG, + INFO, + WARN, + ERROR, + CRITICAL + }; + class Logger + { + public: + Logger(logging_level level, const std::string& log_file) + : level_{ level } + { + output_stream_.open(log_file); + } + Logger(logging_level level) + : level_{ level } + {} + + ~Logger() + { + if (output_stream_.is_open()) + { + output_stream_.close(); + } + } + + void set_debug_level(logging_level level); + void log(logging_level level, const std::string& msg); + void debug(const std::string& msg); + void info(const std::string& msg); + void warn(const std::string& msg); + void critical(const std::string& msg); + void error(const std::string& msg); + + private: + logging_level level_; + std::ofstream output_stream_; + }; +} // namespace LogMe |
