log API 参考
Enumerations
-
enum wm_log_level_t
Description of log level.
Values:
-
enumerator WM_LOG_LEVEL_NONE
No log output
-
enumerator WM_LOG_LEVEL_ERROR
Critical errors
-
enumerator WM_LOG_LEVEL_WARN
warnings
-
enumerator WM_LOG_LEVEL_INFO
Information messages
-
enumerator WM_LOG_LEVEL_DEBUG
Debug informations
-
enumerator WM_LOG_LEVEL_VERBOSE
Extra information which is not necessary
-
enumerator WM_LOG_LEVEL_NONE
Macros
-
WM_LOG_COLOR_E
Log colors define.
-
WM_LOG_COLOR_W
-
WM_LOG_COLOR_I
-
WM_LOG_COLOR_D
-
WM_LOG_COLOR_V
-
WM_LOG_COLOR_END
-
LOG_FMT(letter, fmt)
macro for formating the log line
-
WM_GET_MS(...)
macro for get time stamp
-
LOG_TAG
Log tag name, used to distinguish different logs. To override the default LOG_TAG defined in wm_log. h, you need to define your own LOG_TAG before the. c or. cpp file includes wm_log.h.
警告
Do not define LOG_TAG in the header file for external use, or the definition may be repeated.
-
wm_log_error(fmt, ...)
macro for log wm_log_error
-
wm_log_warn(fmt, ...)
macro for log wm_log_warn
-
wm_log_info(fmt, ...)
macro for log wm_log_info
-
wm_log_debug(fmt, ...)
macro for log wm_log_debug
-
wm_log_verbose(fmt, ...)
macro for log wm_log_verbose
-
wm_log_raw(level, fmt, ...)
macro for log raw data with output level speicified
-
wm_log_raw_error(fmt, ...)
macro for log raw date with level WM_LOG_LEVEL_ERROR.
备注
No TAG, timestamp, level, color and other information will be output.
-
wm_log_raw_warn(fmt, ...)
macro for log raw date with level WM_LOG_LEVEL_WARN
-
wm_log_raw_info(fmt, ...)
macro for log raw date with level WM_LOG_LEVEL_INFO
-
wm_log_raw_debug(fmt, ...)
macro for log raw date with level WM_LOG_LEVEL_DEBUG
-
wm_log_raw_verbose(fmt, ...)
macro for log raw date with level WM_LOG_LEVEL_VERBOSE
-
wm_log_dump(level, name, width, buf, size)
macro for dump data as hex format with output level speicified
The dump log likes this: [E] (565762) at_log: dump [dump_name] 0x0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ……………. 0x0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ……………. 0x0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !”# %&’()*+,-./ 0x0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>? 0x0040 40 41
备注
The recommended width is 16
- 参数:
level – [in] log level
name – [in] the log item name, used to distinguish other dump data
width – [in] the columns of the format data each line
buf – [in] data buffer need show
size – [in] data size
-
wm_log_dump_error(name, buf, size)
macro for log dump binary data as hex format with level WM_LOG_LEVEL_ERROR
-
wm_log_dump_warn(name, buf, size)
macro for log dump binary data as hex format with level WM_LOG_LEVEL_WARN
-
wm_log_dump_info(name, buf, size)
macro for log dump binary data as hex format with level WM_LOG_LEVEL_INFO
-
wm_log_dump_debug(name, buf, size)
macro for log dump binary data as hex format with level WM_LOG_LEVEL_DEBUG
-
wm_log_dump_verbose(name, buf, size)
macro for log dump binary data as hex format with level WM_LOG_LEVEL_VERBOSE
Functions
-
int wm_log_printf(wm_log_level_t level, const char *tag, const char *format, ...)
log printf function
备注
The maximum log length is 16K. If you need to output more data, you can use wm_log_dump_xxx.
- 参数:
level – [in] log level
tag – [in] the log tag
format – [in] format
- 返回:
size of format size
-
int wm_log_hex_dump(wm_log_level_t level, const char *tag, const char *name, uint8_t width, const void *data, size_t data_len)
Output log information in hexadecimal and display its ascii code string.
- 参数:
level – [in] log level
tag – [in] log TAG
name – [in] name for hex object, it will show on log header
width – [in] hex number for every line, such as: 16, 32
data – [in] hex buffer
data_len – [in] buffer size
- 返回:
WM_ERR_SUCCESS : success
WM_ERR_INVALID_PARAM : invalid param
-
int wm_log_vprintf(wm_log_level_t level, const char *tag, const char *format, va_list args)
format output log by arguments list
- 参数:
level – [in] log level
tag – [in] log TAG
format – [in] format parameter
args – [in] Variable length parameter list
- 返回:
size of format size
-
int wm_log_set_level(wm_log_level_t level)
Set log level.
- 参数:
level – [in] log level
- 返回:
WM_ERR_SUCCESS : success
-
wm_log_level_t wm_log_get_level(void)
Get log level.
- 返回:
log level
-
int wm_log_set_vprintf(wm_log_vprintf_t user_vprintf)
set custom vprintf
- 参数:
user_vprintf – [in] user defined vprintf function
- 返回:
WM_ERR_SUCCESS
-
int wm_printf_direct(const char *fmt, ...)
printf directly, output log to uart hardware fifo directly
备注
The output content is not limited by LOG level, it likes printf. It is recommended to use only in scenarios where interrupts have been turned off or the OS cannot be scheduled.
- 参数:
fmt – [in] printf format
- 返回:
WM_ERR_SUCCESS
-
int wm_log_init(void)
Initialize log module.
备注
This API must be called before all other log API can be called
- 返回:
WM_ERR_SUCCESS: succeed
others: failed