diff --git a/Log.h b/Log.h index 284c88d..1cc787c 100644 --- a/Log.h +++ b/Log.h @@ -8,7 +8,7 @@ #include // list of outputs class Log { - public: +public: enum Level { OFF = 0, FATAL, ERROR, WARN, NOTE, INFO, DEBUG, TRACE }; // delete ctors as this class is used via static methods only @@ -22,17 +22,17 @@ class Log { // close all output streams static void stop(); - private: +private: // abstract base class for a log sink class Output { - public: + public: Output(); Output(Log::Level lvl_max); virtual ~Output(); virtual void log(Log::Level lvl, std::stringbuf* sbuf); virtual void setLogLevel(Log::Level lvl); - protected: + protected: Log::Level lvl_max = INFO; // returns the correct ostream for the given log-level // or returns nullptr if no ostream is set/enabled for this level @@ -42,11 +42,11 @@ class Log { // logging to stdout/stderr class ConsoleOutput : public Output { - public: + public: ConsoleOutput(); virtual bool setColoredOutput(bool enabled); - private: + private: std::ostream* osStd = &std::cout; std::ostream* osErr = &std::cerr; bool coloredOutput; @@ -55,11 +55,11 @@ class Log { }; class FileOutput : public Output { - public: + public: FileOutput(const std::string& filename, Log::Level lvl_max); FileOutput(const std::string& filename, Log::Level lvl_min, Log::Level lvl_max); - private: + private: std::string filename; std::ofstream ofs; Log::Level lvl_min = FATAL; @@ -68,7 +68,7 @@ class Log { static std::vector outputs; - public: +public: static void addLogfile(const std::string& filename, Level max); static void addLogfile(const std::string& filename, Level min, Level max); @@ -79,11 +79,11 @@ class Log { // by concatenation with the << operator // Inspired from https://stackoverflow.com/a/8337882 class Entry { - private: + private: std::stringstream ss; Log::Level lvl; - public: + public: Entry(Log::Level lvl) : lvl(lvl) {} Entry(Entry&&) = default; ~Entry() { Log::log(lvl, ss.rdbuf()); }