X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Flog.h;h=94d30de4ecbb109a8b557bc145041c2517685899;hb=d2137ac5db409e686b4d9b3fa567935a5e416d41;hp=d32b368f5a2ed202c3b62658a51c79956bfc8546;hpb=1e8f1be709e8a3fa58f1147db2e58a39396313d8;p=dcpomatic.git diff --git a/src/lib/log.h b/src/lib/log.h index d32b368f5..94d30de4e 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,56 @@ #include #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 - }; + static const int TYPE_GENERAL; + static const int TYPE_WARNING; + static const int TYPE_ERROR; + static const int TYPE_TIMING; - void log (std::string m, Level l = STANDARD); + void log (std::string message, int type); + void microsecond_log (std::string message, int type); - void set_level (Level l); + void set_types (int types); private: - /** mutex to prevent simultaneous writes to the file */ + virtual void do_log (std::string m) = 0; + void config_changed (); + + /** mutex to protect the log */ boost::mutex _mutex; + /** bit-field of log types which should be put into the log (others are ignored) */ + int _types; + boost::signals2::scoped_connection _config_connection; +}; + +class FileLog : public Log +{ +public: + FileLog (boost::filesystem::path file); + +private: + void do_log (std::string m); /** filename to write to */ - std::string _file; - /** level above which to ignore log messages */ - Level _level; + boost::filesystem::path _file; +}; + +class NullLog : public Log +{ +public: + +private: + void do_log (std::string) {} }; #endif