From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/logger/logger.hh | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 graphs/cpp/logger/logger.hh (limited to 'graphs/cpp/logger/logger.hh') 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 +#include + +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 -- cgit v1.2.3