ulog

宏定义

#define ULOG_TAG   __FILE__, __LINE__
 
#define LOG_EMERG   0 /* system is unusable */
 
#define LOG_ALERT   1 /* action must be taken immediately */
 
#define LOG_CRIT   2 /* critical conditions */
 
#define LOG_ERR   3 /* error conditions */
 
#define LOG_WARNING   4 /* warning conditions */
 
#define LOG_NOTICE   5 /* normal, but significant, condition */
 
#define LOG_INFO   6 /* informational message */
 
#define LOG_DEBUG   7 /* debug-level message */
 
#define LOG_NONE   8 /* used in stop filter, all log will pop out */
 
#define LOG(...)   ulog(LOG_ALERT, "AOS", ULOG_TAG, __VA_ARGS__)
 
#define LOGF(mod, ...)   ulog(LOG_CRIT, mod, ULOG_TAG, __VA_ARGS__)
 
#define LOGE(mod, ...)   ulog(LOG_ERR, mod, ULOG_TAG, __VA_ARGS__)
 
#define LOGW(mod, ...)   ulog(LOG_WARNING, mod, ULOG_TAG, __VA_ARGS__)
 
#define LOGI(mod, ...)   ulog(LOG_INFO, mod, ULOG_TAG, __VA_ARGS__)
 
#define LOGD(mod, ...)
 

枚举

enum  aos_log_level_t {
  AOS_LL_NONE = LOG_EMERG , AOS_LL_FATAL = LOG_CRIT , AOS_LL_ERROR = LOG_ERR , AOS_LL_WARN = LOG_WARNING ,
  AOS_LL_INFO = LOG_INFO , AOS_LL_DEBUG = LOG_DEBUG
}
 

函数

int ulog (const unsigned char s, const char *mod, const char *f, const unsigned long l, const char *fmt,...)
 
int aos_set_log_level (aos_log_level_t log_level)
 
int aos_set_log_output (void(*output_func)(const char *fmt,...))
 
void ulog_init (void)
 
int ulog_man (const char *cmd_str)
 
int aos_get_ulog_list (char *buf, const unsigned short len)
 
int aos_log_hexdump (const char *tag, char *buffer, int len)
 

详细描述

Optional policy of log, which can output into default direction, virtual file system, mqtt channel and syslog udp.

宏定义说明

◆ LOG

#define LOG (   ...)    ulog(LOG_ALERT, "AOS", ULOG_TAG, __VA_ARGS__)

Log at the alert level, brief using of ulog.

参数
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h76 行定义.

◆ LOG_ALERT

#define LOG_ALERT   1 /* action must be taken immediately */

在文件 ulog.h33 行定义.

◆ LOG_CRIT

#define LOG_CRIT   2 /* critical conditions */

在文件 ulog.h34 行定义.

◆ LOG_DEBUG

#define LOG_DEBUG   7 /* debug-level message */

在文件 ulog.h39 行定义.

◆ LOG_EMERG

#define LOG_EMERG   0 /* system is unusable */

在文件 ulog.h32 行定义.

◆ LOG_ERR

#define LOG_ERR   3 /* error conditions */

在文件 ulog.h35 行定义.

◆ LOG_INFO

#define LOG_INFO   6 /* informational message */

在文件 ulog.h38 行定义.

◆ LOG_NONE

#define LOG_NONE   8 /* used in stop filter, all log will pop out */

在文件 ulog.h40 行定义.

◆ LOG_NOTICE

#define LOG_NOTICE   5 /* normal, but significant, condition */

在文件 ulog.h37 行定义.

◆ LOG_WARNING

#define LOG_WARNING   4 /* warning conditions */

在文件 ulog.h36 行定义.

◆ LOGD

#define LOGD (   mod,
  ... 
)

Log at debug level, brief using of ulog.

注解
: This Log API take effect only the switcher 'DEBUG' is switch on.
参数
[in]modstring description of module.
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h138 行定义.

◆ LOGE

#define LOGE (   mod,
  ... 
)    ulog(LOG_ERR, mod, ULOG_TAG, __VA_ARGS__)

Log at error level, brief using of ulog.

参数
[in]modstring description of module.
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h104 行定义.

◆ LOGF

#define LOGF (   mod,
  ... 
)    ulog(LOG_CRIT, mod, ULOG_TAG, __VA_ARGS__)

Log at fatal level, brief using of ulog.

参数
[in]modstring description of module.
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h94 行定义.

◆ LOGI

#define LOGI (   mod,
  ... 
)    ulog(LOG_INFO, mod, ULOG_TAG, __VA_ARGS__)

Log at info level, brief using of ulog.

参数
[in]modstring description of module.
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h124 行定义.

◆ LOGW

#define LOGW (   mod,
  ... 
)    ulog(LOG_WARNING, mod, ULOG_TAG, __VA_ARGS__)

Log at warning level, brief using of ulog.

参数
[in]modstring description of module.
[in]...same as printf() usage.
返回
0 on success, negative error on failure.

在文件 ulog.h114 行定义.

◆ ULOG_TAG

#define ULOG_TAG   __FILE__, __LINE__

Important!!! Switch on NDEBUG will make no log produced(except use API LOG), it doesn't work even you try to increase log level.

在文件 ulog.h30 行定义.

枚举类型说明

◆ aos_log_level_t

枚举值
AOS_LL_NONE 
AOS_LL_FATAL 
AOS_LL_ERROR 
AOS_LL_WARN 
AOS_LL_INFO 
AOS_LL_DEBUG 

在文件 ulog.h42 行定义.

函数说明

◆ aos_get_ulog_list()

int aos_get_ulog_list ( char *  buf,
const unsigned short  len 
)

Function prototype for get ulog list recorded in file system. Precondition of use this function is switch on ULOG_POP_FS_ENABLE The result is usually like below: {"time":" 4.500",list:[{"idx":1,"start":" 0.000","end":""}]} context of time is system time when called, list show the start time and end time of special index. If value of end time is empty, means this log file is logging.

参数
[in]bufbuffer received the context of file list
[in]lenlength of buffer
返回
0 sucessfully, -EINVAL param illegal, -ENOMEM not enough room to receive file list, -EIO system error.

◆ aos_log_hexdump()

int aos_log_hexdump ( const char *  tag,
char *  buffer,
int  len 
)

Dump buffer by hex.

参数
[in]tagtag
[in]bufferbuffer
[in]lenbuffer len
返回
zero on success. On error, yoc_err is returned

◆ aos_set_log_level()

int aos_set_log_level ( aos_log_level_t  log_level)

Set the log level.

参数
[in]log_levellevel to be set,must be one of AOS_LL_NONE,AOS_LL_FATAL, AOS_LL_ERROR,AOS_LL_WARN,AOS_LL_INFO or AOS_LL_DEBUG.
返回
0 on success, negative error on failure.

◆ aos_set_log_output()

int aos_set_log_output ( void(*)(const char *fmt,...)  output_func)

Set the log terminal output func.

参数
[in]void(output_func)(const char fmt, ...)
function to output log for terminal in different platform
返回
0 on success, negative error on failure.

◆ ulog()

int ulog ( const unsigned char  s,
const char *  mod,
const char *  f,
const unsigned long  l,
const char *  fmt,
  ... 
)

Function prototype for syncronized log text, Recommed using below brief API LOGX instead of this.

参数
[in]sServerity of Log
[in]modModule name
[in]fUsually File name
[in]lUsually Line number of comment
[in]fmt,...Variable Parameter, support format print to log
返回
0 on success, negative error on failure.

◆ ulog_init()

void ulog_init ( void  )

Function prototype for log init. This is called in system level automatically, it is not necessary calling it in application.

◆ ulog_man()

int ulog_man ( const char *  cmd_str)

Function prototype for ulog management.

参数
[in]cmd_strcommand string, user fill the command string to manage ulog, format shall as below: "tcpip service=1" or "tcpip service=0" to notice the tcpip feature is install or not, which have impact on the ulog pop out via udp session; "listen ip=16777343" to nofice the syslog listener's address is 127.0.0.1; "fspause=1" or "fspause=0" to command pause/resume into file system or not; "ulog file up=1" to notify upload log file 1 via http.
返回
0 on Success, -EINVAL: invalid parameter, -EPERM: ulog module not initied yet, -EACCES: this function not work as there is no ASYNC method using. Other fail reason may come from kernel message queue.