libcdos-fw
CFLog.h
1 #ifndef __CF_LOG_H__
2 #define __CF_LOG_H__
3 
4 #include <Core/CFTypes.h>
5 #include <Core/CFDefines.h>
6 #include <stdarg.h>
7 
8 #define CFLOGI(...) cf_log_Common(TAG, CFLOGLV_INFO, __VA_ARGS__);
9 #define CFLOGD(...) cf_log_Common(TAG, CFLOGLV_DEBUG, __VA_ARGS__);
10 #define CFLOGW(...) cf_log_Common(TAG, CFLOGLV_WARNING, __VA_ARGS__);
11 #define CFLOGE(...) cf_log_Common(TAG, CFLOGLV_ERROR, __VA_ARGS__);
12 #define CFLOGF(...) cf_log_Common(TAG, CFLOGLV_FATAL, __VA_ARGS__);
13 
14 CF_EXPORT void cf_enable_debug();
15 CF_EXPORT void cf_disable_debug();
16 CF_EXPORT void cf_enable_info();
17 CF_EXPORT void cf_disable_info();
18 
19 CF_EXPORT void cf_log_Common(const char* logtag, CFLogLevel level, const char* format, ...);
20 
28 class CFLog {
29 public:
40  static void addLevelMask(unsigned int mask);
41 
52  static void removeLevelMask(unsigned int mask);
53 
66  static void i(const char* tag, const char* format, ...);
67 
80  static void d(const char* tag, const char* format, ...);
81 
92  static void w(const char* tag, const char* format, ...);
93 
104  static void e(const char* tag, const char* format, ...);
105 
116  static void f(const char* tag, const char* format, ...);
117 
128  static void logCommon(CFLogLevel level, const char* tag, const char* format, va_list ap);
129 
130 private:
131  CFLog();
132  CFLog(const CFLog& );
133 
134  static CFLog* getInst();
135 
136  void log(CFLogLevel level, const char* tag, const char* format, va_list ap);
137 
138  void addMask(unsigned int mask);
139  void removeMask(unsigned int mask);
140 
141  char* currentTimeStr();
142 
143 private:
144  static CFLog* s_inst;
145  unsigned int m_mask;
146 };
147 
148 #endif // __CF_LOG_H__
static void e(const char *tag, const char *format,...)
输出CFLOGLV_ERROR级别日志
static void logCommon(CFLogLevel level, const char *tag, const char *format, va_list ap)
输出日志信息
CFLogLevel
日志级别枚举类型
Definition: CFTypes.h:26
static void addLevelMask(unsigned int mask)
增加log输出的级别。
static void i(const char *tag, const char *format,...)
输出CFLOGLV_INFO级别日志
结构与枚举类型定义.
static void w(const char *tag, const char *format,...)
输出CFLOGLV_WARNING级别日志
static void d(const char *tag, const char *format,...)
输出CFLOGLV_DEBUG级别日志
CFLog 类.
Definition: CFLog.h:28
static void f(const char *tag, const char *format,...)
输出CFLOGLV_FATAL级别日志
static void removeLevelMask(unsigned int mask)
关闭log输出的级别。