17 #ifndef __NUGU_LOG_H__
18 #define __NUGU_LOG_H__
48 #ifndef NUGU_ANSI_COLOR_NORMAL
49 #ifdef NUGU_LOG_USE_ANSICOLOR
50 #define NUGU_ANSI_COLOR_NORMAL "\x1b[0m"
52 #define NUGU_ANSI_COLOR_NORMAL ""
56 #ifndef NUGU_ANSI_COLOR_BLACK
57 #define NUGU_ANSI_COLOR_BLACK "\x1b[0;30m"
60 #ifndef NUGU_ANSI_COLOR_RED
61 #define NUGU_ANSI_COLOR_RED "\x1b[0;31m"
64 #ifndef NUGU_ANSI_COLOR_GREEN
65 #define NUGU_ANSI_COLOR_GREEN "\x1b[0;32m"
68 #ifndef NUGU_ANSI_COLOR_BROWN
69 #define NUGU_ANSI_COLOR_BROWN "\x1b[0;33m"
72 #ifndef NUGU_ANSI_COLOR_BLUE
73 #define NUGU_ANSI_COLOR_BLUE "\x1b[0;34m"
76 #ifndef NUGU_ANSI_COLOR_MAGENTA
77 #define NUGU_ANSI_COLOR_MAGENTA "\x1b[0;35m"
80 #ifndef NUGU_ANSI_COLOR_CYAN
81 #define NUGU_ANSI_COLOR_CYAN "\x1b[0;36m"
84 #ifndef NUGU_ANSI_COLOR_LIGHTGRAY
85 #define NUGU_ANSI_COLOR_LIGHTGRAY "\x1b[0;37m"
88 #ifndef NUGU_ANSI_COLOR_DARKGRAY
89 #define NUGU_ANSI_COLOR_DARKGRAY "\x1b[1;30m"
92 #ifndef NUGU_ANSI_COLOR_LIGHTRED
93 #define NUGU_ANSI_COLOR_LIGHTRED "\x1b[1;31m"
96 #ifndef NUGU_ANSI_COLOR_LIGHTGREEN
97 #define NUGU_ANSI_COLOR_LIGHTGREEN "\x1b[1;32m"
100 #ifndef NUGU_ANSI_COLOR_YELLOW
101 #define NUGU_ANSI_COLOR_YELLOW "\x1b[1;33m"
104 #ifndef NUGU_ANSI_COLOR_LIGHTBLUE
105 #define NUGU_ANSI_COLOR_LIGHTBLUE "\x1b[1;34m"
108 #ifndef NUGU_ANSI_COLOR_LIGHTMAGENTA
109 #define NUGU_ANSI_COLOR_LIGHTMAGENTA "\x1b[1;35m"
112 #ifndef NUGU_ANSI_COLOR_LIGHTCYAN
113 #define NUGU_ANSI_COLOR_LIGHTCYAN "\x1b[1;36m"
116 #ifndef NUGU_ANSI_COLOR_WHITE
117 #define NUGU_ANSI_COLOR_WHITE "\x1b[1;37m"
199 #ifndef NUGU_LOG_MODULE
206 #define NUGU_LOG_MODULE NUGU_LOG_MODULE_DEFAULT
224 const char *funcname,
int line,
const char *format,
240 const char *msg,
void *user_data);
326 size_t data_size,
const char *header,
327 const char *footer,
const char *lineindent);
334 #define __FILENAME__ __FILE__
346 #define nugu_log(module, level, fmt, ...) \
347 nugu_log_print(module, level, __FILENAME__, __FUNCSIG__, __LINE__, \
350 #define nugu_log(module, level, fmt, ...) \
351 nugu_log_print(module, level, __FILENAME__, __PRETTY_FUNCTION__, \
352 __LINE__, fmt, ##__VA_ARGS__)
355 #ifdef CONFIG_RELEASE
356 #define nugu_dbg(fmt, ...)
357 #define nugu_info(fmt, ...)
358 #define nugu_warn(fmt, ...)
366 #define nugu_dbg(fmt, ...) \
367 nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
374 #define nugu_info(fmt, ...) \
375 nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
382 #define nugu_warn(fmt, ...) \
383 nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_WARNING, fmt, ##__VA_ARGS__)
391 #define nugu_error(fmt, ...) \
392 nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
394 #ifndef NUGU_ANSI_COLOR_SEND
395 #ifdef NUGU_LOG_USE_ANSICOLOR
396 #define NUGU_ANSI_COLOR_SEND NUGU_ANSI_COLOR_BROWN
398 #define NUGU_ANSI_COLOR_SEND ""
402 #ifndef NUGU_ANSI_COLOR_RECV
403 #ifdef NUGU_LOG_USE_ANSICOLOR
404 #define NUGU_ANSI_COLOR_RECV NUGU_ANSI_COLOR_GREEN
406 #define NUGU_ANSI_COLOR_RECV ""
410 #ifndef NUGU_LOG_MARK_SEND
411 #define NUGU_LOG_MARK_SEND "--> "
414 #ifndef NUGU_LOG_MARK_RECV
415 #define NUGU_LOG_MARK_RECV "<-- "
425 #define nugu_log_protocol_send(level, fmt, ...) \
426 nugu_log_print(NUGU_LOG_MODULE_PROTOCOL, level, NULL, NULL, -1, \
427 NUGU_ANSI_COLOR_SEND NUGU_LOG_MARK_SEND fmt \
428 NUGU_ANSI_COLOR_NORMAL, \
438 #define nugu_log_protocol_recv(level, fmt, ...) \
439 nugu_log_print(NUGU_LOG_MODULE_PROTOCOL, level, NULL, NULL, -1, \
440 NUGU_ANSI_COLOR_RECV NUGU_LOG_MARK_RECV fmt \
441 NUGU_ANSI_COLOR_NORMAL, \
448 #define nugu_error_nomem() nugu_error("Not enough memory")
nugu_log_prefix
logging prefix
Definition: nugu_log.h:152
NUGU_API enum nugu_log_prefix nugu_log_get_prefix_fields(void)
Get the additional information fields.
NUGU_API unsigned int nugu_log_get_modules(void)
Get the bitset of modules.
NUGU_API enum nugu_log_system nugu_log_get_system(void)
Get logging backend system.
NUGU_API enum nugu_log_level nugu_log_get_level(void)
Get log level.
NUGU_API void nugu_hexdump(enum nugu_log_module module, const uint8_t *data, size_t data_size, const char *header, const char *footer, const char *lineindent)
Hexdump the specific data to stderr.
NUGU_API int nugu_log_get_protocol_line_limit(void)
Get the maximum length of each protocol log line.
NUGU_API void nugu_log_set_prefix_fields(enum nugu_log_prefix field_set)
Set the additional information fields.
NUGU_API void nugu_log_print(enum nugu_log_module module, enum nugu_log_level level, const char *filename, const char *funcname, int line, const char *format,...)
logging function
NUGU_API int nugu_log_set_handler(nugu_log_handler handler, void *user_data)
Set custom log handler.
nugu_log_level
log levels.
Definition: nugu_log.h:128
NUGU_API void nugu_log_set_protocol_line_limit(int length)
Set the maximum length of each protocol log line.
nugu_log_system
Back-end system that supports log output.
Definition: nugu_log.h:140
NUGU_API void nugu_log_set_level(enum nugu_log_level level)
Set minimum log level(debug, info, warning, error) For example, if set the level to info,...
void(* nugu_log_handler)(enum nugu_log_module module, enum nugu_log_level level, const char *prefix, const char *msg, void *user_data)
Custom log hook handler.
Definition: nugu_log.h:238
NUGU_API void nugu_log_set_modules(unsigned int bitset)
Set the bitset of modules.
NUGU_API int nugu_log_set_system(enum nugu_log_system log_system)
Set logging backend system.
nugu_log_module
logging modules
Definition: nugu_log.h:177
@ NUGU_LOG_PREFIX_PID
Definition: nugu_log.h:155
@ NUGU_LOG_PREFIX_LEVEL
Definition: nugu_log.h:157
@ NUGU_LOG_PREFIX_FILENAME
Definition: nugu_log.h:159
@ NUGU_LOG_PREFIX_FILEPATH
Definition: nugu_log.h:158
@ NUGU_LOG_PREFIX_ALL
Definition: nugu_log.h:167
@ NUGU_LOG_PREFIX_LINE
Definition: nugu_log.h:161
@ NUGU_LOG_PREFIX_DEFAULT
Definition: nugu_log.h:162
@ NUGU_LOG_PREFIX_TIMESTAMP
Definition: nugu_log.h:154
@ NUGU_LOG_PREFIX_FUNCTION
Definition: nugu_log.h:160
@ NUGU_LOG_PREFIX_NONE
Definition: nugu_log.h:153
@ NUGU_LOG_PREFIX_TID
Definition: nugu_log.h:156
@ NUGU_LOG_LEVEL_ERROR
Definition: nugu_log.h:129
@ NUGU_LOG_LEVEL_WARNING
Definition: nugu_log.h:130
@ NUGU_LOG_LEVEL_DEBUG
Definition: nugu_log.h:132
@ NUGU_LOG_LEVEL_INFO
Definition: nugu_log.h:131
@ NUGU_LOG_SYSTEM_NONE
Definition: nugu_log.h:144
@ NUGU_LOG_SYSTEM_CUSTOM
Definition: nugu_log.h:145
@ NUGU_LOG_SYSTEM_STDERR
Definition: nugu_log.h:141
@ NUGU_LOG_SYSTEM_STDOUT
Definition: nugu_log.h:142
@ NUGU_LOG_SYSTEM_SYSLOG
Definition: nugu_log.h:143
@ NUGU_LOG_MODULE_NETWORK_TRACE
Definition: nugu_log.h:180
@ NUGU_LOG_MODULE_NETWORK
Definition: nugu_log.h:179
@ NUGU_LOG_MODULE_APPLICATION
Definition: nugu_log.h:184
@ NUGU_LOG_MODULE_DEFAULT
Definition: nugu_log.h:178
@ NUGU_LOG_MODULE_PROTOCOL
Definition: nugu_log.h:182
@ NUGU_LOG_MODULE_PRESET_DEFAULT
Definition: nugu_log.h:189
@ NUGU_LOG_MODULE_ALL
Definition: nugu_log.h:196
@ NUGU_LOG_MODULE_PRESET_SDK_DEFAULT
Definition: nugu_log.h:185
@ NUGU_LOG_MODULE_AUDIO
Definition: nugu_log.h:181
@ NUGU_LOG_MODULE_PROFILING
Definition: nugu_log.h:183
@ NUGU_LOG_MODULE_PRESET_NETWORK
Definition: nugu_log.h:192