X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Flog.h;h=991532404293a7a01fc59762b3b1b8b0d15af6ec;hb=2d5b8cdde08044d323aa7193dfac6c9f8bca7131;hp=d32b368f5a2ed202c3b62658a51c79956bfc8546;hpb=1e8f1be709e8a3fa58f1147db2e58a39396313d8;p=dcpomatic.git diff --git a/src/lib/log.h b/src/lib/log.h index d32b368f5..991532404 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -17,8 +17,8 @@ */ -#ifndef DVDOMATIC_LOG_H -#define DVDOMATIC_LOG_H +#ifndef DCPOMATIC_LOG_H +#define DCPOMATIC_LOG_H /** @file src/log.h * @brief A very simple logging class. @@ -26,35 +26,57 @@ #include #include +#include /** @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 +class Log : public boost::noncopyable { 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 (boost::filesystem::path file); + +private: + void do_log (std::string m); + /** filename to write to */ + boost::filesystem::path _file; +}; + +class NullLog : public Log +{ +public: + +private: + void do_log (std::string) {} +}; + #endif