/* */ #ifndef D_LOGGER_H #define D_LOGGER_H #include "common.h" #include #include namespace aria2 { class Exception; class Logger { public: enum LEVEL { A2_DEBUG = 1 << 0, A2_INFO = 1 << 1, A2_NOTICE = 1 << 2, A2_WARN = 1 << 3, A2_ERROR = 1 << 4, }; private: LEVEL logLevel_; std::ofstream file_; int stdoutField_; // Don't allow copying Logger(const Logger&); Logger& operator=(const Logger&); public: Logger(); ~Logger(); void log (LEVEL level, const char* sourceFile, int lineNum, const char* msg); void log (LEVEL level, const char* sourceFile, int lineNum, const std::string& msg); void log (LEVEL level, const char* sourceFile, int lineNum, const char* msg, const Exception& ex); void log (LEVEL level, const char* sourceFile, int lineNum, const std::string& msg, const Exception& ex); void openFile(const std::string& filename); void closeFile(); void setLogLevel(LEVEL level) { logLevel_ = level; } void setStdoutLogLevel(Logger::LEVEL level, bool enabled); // Returns true if this logger actually writes debug log message to // either file or stdout. bool levelEnabled(LEVEL level); }; } // namespace aria2 #endif // D_LOGGER_H