X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Flog.h;h=3a2cfcbfd53e7882a61feaa03268738036a60b1f;hb=9bdd8cc51942a13e360dde4efc04b3ca417c8b94;hp=d4de8ebde6ff466110b2b49ae67e51ab6ae6c6c9;hpb=bb767c7e338414beee132af3e96829c1448e214b;p=dcpomatic.git diff --git a/src/lib/log.h b/src/lib/log.h index d4de8ebde..3a2cfcbfd 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -17,6 +17,9 @@ */ +#ifndef DVDOMATIC_LOG_H +#define DVDOMATIC_LOG_H + /** @file src/log.h * @brief A very simple logging class. */ @@ -26,30 +29,45 @@ /** @class Log * @brief A very simple logging class. - * - * This class simply accepts log messages and writes them to a file. - * Its single nod to complexity is that it has a mutex to prevent - * multi-thread logging from clashing. */ class Log { public: - Log (std::string f); + Log (); + virtual ~Log () {} enum Level { STANDARD = 0, - VERBOSE = 1 + VERBOSE = 1, + TIMING = 2 }; void log (std::string m, Level l = STANDARD); + void microsecond_log (std::string m, Level l = STANDARD); void set_level (Level l); + void set_level (std::string l); -private: - /** mutex to prevent simultaneous writes to the file */ +protected: + /** mutex to protect the log */ boost::mutex _mutex; - /** filename to write to */ - std::string _file; + +private: + virtual void do_log (std::string m) = 0; + /** level above which to ignore log messages */ Level _level; }; + +class FileLog : public Log +{ +public: + FileLog (std::string file); + +private: + void do_log (std::string m); + /** filename to write to */ + std::string _file; +}; + +#endif