ulog.h
浏览该文件的文档.
1 
6 #ifndef ULOG_H
7 #define ULOG_H
8 
9 #include <string.h>
10 #include "ulog_config.h"
22 #ifdef NDEBUG
23 #define CONFIG_LOGMACRO_SILENT
24 #endif
25 
26 #if defined(CONFIG_DEBUG) && CONFIG_DEBUG
27 #define DEBUG
28 #endif
29 
30 #define ULOG_TAG __FILE__, __LINE__
31 
32 #define LOG_EMERG 0 /* system is unusable */
33 #define LOG_ALERT 1 /* action must be taken immediately */
34 #define LOG_CRIT 2 /* critical conditions */
35 #define LOG_ERR 3 /* error conditions */
36 #define LOG_WARNING 4 /* warning conditions */
37 #define LOG_NOTICE 5 /* normal, but significant, condition */
38 #define LOG_INFO 6 /* informational message */
39 #define LOG_DEBUG 7 /* debug-level message */
40 #define LOG_NONE 8 /* used in stop filter, all log will pop out */
41 
42 typedef enum {
43  AOS_LL_NONE = LOG_EMERG, /* disable log */
44  AOS_LL_FATAL = LOG_CRIT, /* fatal log will output */
45  AOS_LL_ERROR = LOG_ERR, /* fatal + error log will output */
46  AOS_LL_WARN = LOG_WARNING, /* fatal + warn + error log will output(default level) */
47  AOS_LL_INFO = LOG_INFO, /* info + warn + error log will output */
48  AOS_LL_DEBUG = LOG_DEBUG, /* debug + info + warn + error + fatal log will output */
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
66 int ulog(const unsigned char s, const char *mod, const char *f,
67  const unsigned long l, const char *fmt, ...);
68 
76 #define LOG(...) ulog(LOG_ALERT, "AOS", ULOG_TAG, __VA_ARGS__)
77 
78 #ifdef CONFIG_LOGMACRO_SILENT
79 #define LOGF(mod, ...)
80 #define LOGE(mod, ...)
81 #define LOGW(mod, ...)
82 #define LOGI(mod, ...)
83 #define LOGD(mod, ...)
84 
85 #else /* !CONFIG_LOGMACRO_SILENT */
94 #define LOGF(mod, ...) ulog(LOG_CRIT, mod, ULOG_TAG, __VA_ARGS__)
95 
104 #define LOGE(mod, ...) ulog(LOG_ERR, mod, ULOG_TAG, __VA_ARGS__)
105 
114 #define LOGW(mod, ...) ulog(LOG_WARNING, mod, ULOG_TAG, __VA_ARGS__)
115 
124 #define LOGI(mod, ...) ulog(LOG_INFO, mod, ULOG_TAG, __VA_ARGS__)
125 
135 #ifdef DEBUG
136 #define LOGD(mod, ...) ulog(LOG_DEBUG, mod, ULOG_TAG, __VA_ARGS__)
137 #else
138 #define LOGD(mod, ...)
139 #endif
140 
141 #endif /* CONFIG_LOGMACRO_SILENT */
142 
152 
161 int aos_set_log_output(void (*output_func)(const char* fmt, ...));
162 
163 #if ULOG_POP_CLOUD_ENABLE
164 int aos_set_popcloud_log_level(aos_log_level_t log_level);
165 #endif
166 
167 #if ULOG_POP_FS_ENABLE
168 int ulog_fs_log_file_size(unsigned int filesize);
169 int ulog_fs_log_file_path(char *filepath);
170 int aos_set_popfs_log_level(aos_log_level_t log_level);
171 #endif
172 
173 #if ULOG_POP_UDP_ENABLE
174 int aos_set_popudp_log_level(aos_log_level_t log_level);
175 #endif
176 
182 void ulog_init(void);
183 
199 int ulog_man(const char *cmd_str);
200 
215 int aos_get_ulog_list(char *buf, const unsigned short len);
216 
224 int aos_log_hexdump(const char* tag, char *buffer, int len);
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
232 #endif /* ULOG_H */
233 
int ulog(const unsigned char s, const char *mod, const char *f, const unsigned long l, const char *fmt,...)
int aos_get_ulog_list(char *buf, const unsigned short len)
#define LOG_EMERG
Definition: ulog.h:32
#define LOG_DEBUG
Definition: ulog.h:39
int aos_log_hexdump(const char *tag, char *buffer, int len)
#define LOG_ERR
Definition: ulog.h:35
int aos_set_log_output(void(*output_func)(const char *fmt,...))
#define LOG_CRIT
Definition: ulog.h:34
aos_log_level_t
Definition: ulog.h:42
int aos_set_log_level(aos_log_level_t log_level)
#define LOG_WARNING
Definition: ulog.h:36
int ulog_man(const char *cmd_str)
void ulog_init(void)
#define LOG_INFO
Definition: ulog.h:38
@ AOS_LL_WARN
Definition: ulog.h:46
@ AOS_LL_INFO
Definition: ulog.h:47
@ AOS_LL_ERROR
Definition: ulog.h:45
@ AOS_LL_NONE
Definition: ulog.h:43
@ AOS_LL_DEBUG
Definition: ulog.h:48
@ AOS_LL_FATAL
Definition: ulog.h:44