From 160e1299ef3d95f8e8c48706d7f61dd3dc6c6b60 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 11 Feb 2020 11:29:07 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=20tab=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/utils/log.h | 76 +++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/libjin/utils/log.h') diff --git a/src/libjin/utils/log.h b/src/libjin/utils/log.h index 11b4897..961df7a 100644 --- a/src/libjin/utils/log.h +++ b/src/libjin/utils/log.h @@ -11,52 +11,52 @@ class Loghelper { public: - // log输出目标 - enum Direction - { - DIR_CERR = 1 << 1, // 标准错误流 - DIR_FILE = 1 << 2, // log文件 - }; - - // 错误等级 - enum Level - { - LV_NONE = 0, // none - LV_ERROR = 1 << 1, // error - LV_WARNING = 1 << 2, // warn - LV_INFO = 1 << 3, // info - LV_DEBUG = 1 << 4, // debug - LV_ALL = 0xffffffff - }; - - static void log(Level _level, const char* _fmt, ...); - - // 重定向 - static void redirect(unsigned int _dir, char* _path = nullptr); - - // 筛选错误等级 - static void restrict(unsigned int levels); - - static void close(); + // log输出目标 + enum Direction + { + DIR_CERR = 1 << 1, // 标准错误流 + DIR_FILE = 1 << 2, // log文件 + }; + + // 错误等级 + enum Level + { + LV_NONE = 0, // none + LV_ERROR = 1 << 1, // error + LV_WARNING = 1 << 2, // warn + LV_INFO = 1 << 3, // info + LV_DEBUG = 1 << 4, // debug + LV_ALL = 0xffffffff + }; + + static void log(Level _level, const char* _fmt, ...); + + // 重定向 + static void redirect(unsigned int _dir, char* _path = nullptr); + + // 筛选错误等级 + static void restrict(unsigned int levels); + + static void close(); private: - static unsigned int dir; // 输出目标 - static unsigned int levels; // 错误等级 - static std::ofstream fs; // 输出文件流 + static unsigned int dir; // 输出目标 + static unsigned int levels; // 错误等级 + static std::ofstream fs; // 输出文件流 }; typedef Loghelper::Level Loglevel; #if defined(jin_debug) - #define jin_log_error(f, ...) Loghelper::log(Loghelper::LV_ERROR, f, __VA_ARGS__) - #define jin_log_info(f, ...) Loghelper::log(Loghelper::LV_INFO, f, __VA_ARGS__) - #define jin_log_warning(f, ...) Loghelper::log(Loghelper::LV_WARNING, f, __VA_ARGS__) - #define jin_log_debug(f, ...) Loghelper::log(Loghelper::LV_DEBUG, f, __VA_ARGS__) + #define jin_log_error(f, ...) Loghelper::log(Loghelper::LV_ERROR, f, __VA_ARGS__) + #define jin_log_info(f, ...) Loghelper::log(Loghelper::LV_INFO, f, __VA_ARGS__) + #define jin_log_warning(f, ...) Loghelper::log(Loghelper::LV_WARNING, f, __VA_ARGS__) + #define jin_log_debug(f, ...) Loghelper::log(Loghelper::LV_DEBUG, f, __VA_ARGS__) #else - #define jin_log_error(f, ...) - #define jin_log_info(f, ...) - #define jin_log_warning(f, ...) - #define jin_log_debug(f, ...) + #define jin_log_error(f, ...) + #define jin_log_info(f, ...) + #define jin_log_warning(f, ...) + #define jin_log_debug(f, ...) #endif #endif // __LOG_H__ELPER_H__ \ No newline at end of file -- cgit v1.1-26-g67d0