NUGU SDK Linux
1.7.6
|
Log functions. More...
Macros | |
#define | __FILENAME__ __FILE__ |
#define | NUGU_ANSI_COLOR_BLACK "\x1b[0;30m" |
#define | NUGU_ANSI_COLOR_BLUE "\x1b[0;34m" |
#define | NUGU_ANSI_COLOR_BROWN "\x1b[0;33m" |
#define | NUGU_ANSI_COLOR_CYAN "\x1b[0;36m" |
#define | NUGU_ANSI_COLOR_DARKGRAY "\x1b[1;30m" |
#define | NUGU_ANSI_COLOR_GREEN "\x1b[0;32m" |
#define | NUGU_ANSI_COLOR_LIGHTBLUE "\x1b[1;34m" |
#define | NUGU_ANSI_COLOR_LIGHTCYAN "\x1b[1;36m" |
#define | NUGU_ANSI_COLOR_LIGHTGRAY "\x1b[0;37m" |
#define | NUGU_ANSI_COLOR_LIGHTGREEN "\x1b[1;32m" |
#define | NUGU_ANSI_COLOR_LIGHTMAGENTA "\x1b[1;35m" |
#define | NUGU_ANSI_COLOR_LIGHTRED "\x1b[1;31m" |
#define | NUGU_ANSI_COLOR_MAGENTA "\x1b[0;35m" |
#define | NUGU_ANSI_COLOR_NORMAL "" |
#define | NUGU_ANSI_COLOR_RECV "" |
#define | NUGU_ANSI_COLOR_RED "\x1b[0;31m" |
#define | NUGU_ANSI_COLOR_SEND "" |
#define | NUGU_ANSI_COLOR_WHITE "\x1b[1;37m" |
#define | NUGU_ANSI_COLOR_YELLOW "\x1b[1;33m" |
#define | nugu_dbg(fmt, ...) nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__) |
Debug level error message. More... | |
#define | nugu_error(fmt, ...) nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__) |
Error level error message. More... | |
#define | nugu_error_nomem() nugu_error("Not enough memory") |
Default error message for 'Not enough memory'. More... | |
#define | nugu_info(fmt, ...) nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__) |
Information level error message. More... | |
#define | nugu_log(module, level, fmt, ...) |
Convenient macro to fill file, function and line information. More... | |
#define | NUGU_LOG_MARK_RECV "<-- " |
#define | NUGU_LOG_MARK_SEND "--> " |
#define | NUGU_LOG_MODULE NUGU_LOG_MODULE_DEFAULT |
Set default log module. More... | |
#define | nugu_log_protocol_recv(level, fmt, ...) |
Protocol log message for receiving. More... | |
#define | nugu_log_protocol_send(level, fmt, ...) |
Protocol log message for sending. More... | |
#define | nugu_warn(fmt, ...) nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_WARNING, fmt, ##__VA_ARGS__) |
Warning level error message. More... | |
Typedefs | |
typedef 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. More... | |
Functions | |
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. More... | |
NUGU_API enum nugu_log_level | nugu_log_get_level (void) |
Get log level. More... | |
NUGU_API unsigned int | nugu_log_get_modules (void) |
Get the bitset of modules. More... | |
NUGU_API enum nugu_log_prefix | nugu_log_get_prefix_fields (void) |
Get the additional information fields. More... | |
NUGU_API int | nugu_log_get_protocol_line_limit (void) |
Get the maximum length of each protocol log line. More... | |
NUGU_API enum nugu_log_system | nugu_log_get_system (void) |
Get logging backend system. More... | |
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 More... | |
NUGU_API int | nugu_log_set_handler (nugu_log_handler handler, void *user_data) |
Set custom log handler. More... | |
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, debug is discarded, and only logs with info, warning, and error levels are displayed. More... | |
NUGU_API void | nugu_log_set_modules (unsigned int bitset) |
Set the bitset of modules. More... | |
NUGU_API void | nugu_log_set_prefix_fields (enum nugu_log_prefix field_set) |
Set the additional information fields. More... | |
NUGU_API void | nugu_log_set_protocol_line_limit (int length) |
Set the maximum length of each protocol log line. More... | |
NUGU_API int | nugu_log_set_system (enum nugu_log_system log_system) |
Set logging backend system. More... | |
Log functions.
The log function supports standard error output and the syslog system, and you can set the handler you want if necessary.
Supported features:
The log function also supports setting logs at runtime using the environment variables below.
#define NUGU_LOG_MODULE NUGU_LOG_MODULE_DEFAULT |
Set default log module.
#define nugu_log | ( | module, | |
level, | |||
fmt, | |||
... | |||
) |
Convenient macro to fill file, function and line information.
[in] | module | log module name |
[in] | level | logging level |
[in] | fmt | printf format string |
#define nugu_dbg | ( | fmt, | |
... | |||
) | nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__) |
#define nugu_info | ( | fmt, | |
... | |||
) | nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__) |
#define nugu_warn | ( | fmt, | |
... | |||
) | nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_WARNING, fmt, ##__VA_ARGS__) |
#define nugu_error | ( | fmt, | |
... | |||
) | nugu_log(NUGU_LOG_MODULE, NUGU_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__) |
#define nugu_log_protocol_send | ( | level, | |
fmt, | |||
... | |||
) |
Protocol log message for sending.
[in] | level | logging level |
[in] | fmt | printf format string |
#define nugu_log_protocol_recv | ( | level, | |
fmt, | |||
... | |||
) |
Protocol log message for receiving.
[in] | level | logging level |
[in] | fmt | printf format string |
#define nugu_error_nomem | ( | ) | nugu_error("Not enough memory") |
Default error message for 'Not enough memory'.
typedef 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.
[in] | module | log module |
[in] | level | log level |
[in] | prefix | generated additional information (e.g. timestamp, line number) |
[in] | msg | original log message |
[in] | user_data | The user data passed from the callback function |
enum nugu_log_level |
log levels.
When building in release mode, logs at the warning, info, and debug levels are all ignored.
Enumerator | |
---|---|
NUGU_LOG_LEVEL_ERROR | Error level |
NUGU_LOG_LEVEL_WARNING | Warning level |
NUGU_LOG_LEVEL_INFO | Information level |
NUGU_LOG_LEVEL_DEBUG | Debug level |
enum nugu_log_system |
enum nugu_log_prefix |
logging prefix
enum nugu_log_module |
logging modules
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
[in] | module | log module |
[in] | level | log level |
[in] | filename | source file name (e.g. FILE) |
[in] | funcname | function name (e.g. FUNCTION) |
[in] | line | source file line number |
[in] | format | printf format string |
NUGU_API int nugu_log_set_system | ( | enum nugu_log_system | log_system | ) |
Set logging backend system.
NUGU_API enum nugu_log_system nugu_log_get_system | ( | void | ) |
Get logging backend system.
NUGU_API int nugu_log_set_handler | ( | nugu_log_handler | handler, |
void * | user_data | ||
) |
Set custom log handler.
[in] | handler | callback |
[in] | user_data | The user data to be passed to the callback function |
NUGU_API void nugu_log_set_prefix_fields | ( | enum nugu_log_prefix | field_set | ) |
Set the additional information fields.
[in] | field_set | bitmask by enum nugu_log_prefix |
NUGU_API enum nugu_log_prefix nugu_log_get_prefix_fields | ( | void | ) |
Get the additional information fields.
NUGU_API void nugu_log_set_modules | ( | unsigned int | bitset | ) |
Set the bitset of modules.
[in] | bitset | bitmask by enum nugu_log_prefix |
NUGU_API unsigned int nugu_log_get_modules | ( | void | ) |
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, debug is discarded, and only logs with info, warning, and error levels are displayed.
[in] | level | log level |
NUGU_API enum nugu_log_level nugu_log_get_level | ( | void | ) |
Get log level.
NUGU_API void nugu_log_set_protocol_line_limit | ( | int | length | ) |
Set the maximum length of each protocol log line.
[in] | length | line length. -1 means unlimited. |
NUGU_API int nugu_log_get_protocol_line_limit | ( | void | ) |
Get the maximum length of each protocol log line.
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.
[in] | module | log module |
[in] | data | memory address to hexdump |
[in] | data_size | size |
[in] | header | message to be printed at the top of hexdump |
[in] | footer | message to be printed at the bottom of hexdump |
[in] | lineindent | message to be printed at the beginning of each line |