NUGU SDK Linux  1.7.6
nugu_log.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <nugu.h>
+ Include dependency graph for nugu_log.h:

Go to the source code of this file.

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...
 

Enumerations

enum  nugu_log_level { NUGU_LOG_LEVEL_ERROR , NUGU_LOG_LEVEL_WARNING , NUGU_LOG_LEVEL_INFO , NUGU_LOG_LEVEL_DEBUG }
 log levels. More...
 
enum  nugu_log_module {
  NUGU_LOG_MODULE_DEFAULT = 0x01 , NUGU_LOG_MODULE_NETWORK = 0x02 , NUGU_LOG_MODULE_NETWORK_TRACE = 0x04 , NUGU_LOG_MODULE_AUDIO = 0x08 ,
  NUGU_LOG_MODULE_PROTOCOL = 0x10 , NUGU_LOG_MODULE_PROFILING = 0x20 , NUGU_LOG_MODULE_APPLICATION = 0x40 , NUGU_LOG_MODULE_PRESET_SDK_DEFAULT ,
  NUGU_LOG_MODULE_PRESET_DEFAULT , NUGU_LOG_MODULE_PRESET_NETWORK , NUGU_LOG_MODULE_ALL = 0xFF
}
 logging modules More...
 
enum  nugu_log_prefix {
  NUGU_LOG_PREFIX_NONE = 0 , NUGU_LOG_PREFIX_TIMESTAMP = (1 << 0) , NUGU_LOG_PREFIX_PID = (1 << 1) , NUGU_LOG_PREFIX_TID = (1 << 2) ,
  NUGU_LOG_PREFIX_LEVEL = (1 << 3) , NUGU_LOG_PREFIX_FILEPATH = (1 << 4) , NUGU_LOG_PREFIX_FILENAME = (1 << 5) , NUGU_LOG_PREFIX_FUNCTION = (1 << 6) ,
  NUGU_LOG_PREFIX_LINE = (1 << 7) , NUGU_LOG_PREFIX_DEFAULT , NUGU_LOG_PREFIX_ALL
}
 logging prefix More...
 
enum  nugu_log_system {
  NUGU_LOG_SYSTEM_STDERR , NUGU_LOG_SYSTEM_STDOUT , NUGU_LOG_SYSTEM_SYSLOG , NUGU_LOG_SYSTEM_NONE ,
  NUGU_LOG_SYSTEM_CUSTOM
}
 Back-end system that supports log output. 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...