summaryrefslogtreecommitdiff
path: root/graphs/cpp/logger/logger.hh
diff options
context:
space:
mode:
Diffstat (limited to 'graphs/cpp/logger/logger.hh')
-rw-r--r--graphs/cpp/logger/logger.hh47
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