Log Configuration

The Log Configuration quick_dev\common\log\log.h is the configuration that package one layer on bottom layer tracer_log in sdk\SDK\APS\middleware\netlink\msg\msg.h. The log configuration can help developer to trace and debug in application, the log can divide into four types that are debug, information, warnnimg and error. The developer can switch the log level that they want to see according to their needs. To enter tracer level <task_index> <task_level:hex> could turn on tracer level in debug console.

If wanting to trace log with Log Configration, the developer could use tracer_def_level_set() to set trcae log. The developer can refer to the following examples

static void Main_AppInit_patch(void)
{
    sys_cfg_clk_set(SYS_CFG_CLK_RATE);

    // set default tracer level in user app type to INFO, WARN, ERRO (DEBG not open)
    tracer_def_level_set(TRACER_TASK_TYPE_APP, 0x06);

    APP_MainInit();
}

The argument TRACER_TASK_TYPE_APP is a trace type that include TRACER_TASK_TYPE_INTERNAL (bottom layer) and TRACER_TASK_TYPE_APP (application) defined in sdk\SDK\APS\middleware\netlink\msg\msg.h.

typedef enum
{
    TRACER_TASK_TYPE_INTERNAL = 0,
    TRACER_TASK_TYPE_APP,

    TRACER_TASK_TYPE_MAX
} T_TracerTaskType;

The other argument 0x06 is trace level that developer want to trace. There are the following trace level in sdk\SDK\APS\middleware\netlink\msg\msg.h.

#define LOG_HIGH_LEVEL              0x04
#define LOG_MED_LEVEL               0x02
#define LOG_LOW_LEVEL               0x01
#define LOG_NONE_LEVEL              0x00
#define LOG_ALL_LEVEL               (LOG_HIGH_LEVEL | LOG_MED_LEVEL | LOG_LOW_LEVEL)

The argument 0x06 means trace log level turn on LOG_HIGH_LEVEL and LOG_MED_LEVEL but LOG_LOW_LEVEL is turn off. Log Configuration has the following log levels :

  • Debug (LOG_LOW_LEVEL)
#define OPL_LOG_DEBG(module, ...)                                           \
        {                                                                   \
            tracer_log(LOG_LOW_LEVEL, "\x1B[0m[D][%s]", #module);           \
            tracer_log(LOG_LOW_LEVEL, __VA_ARGS__);                         \
            tracer_log(LOG_LOW_LEVEL, "\r\n");                              \
        }
  • Info (LOG_MED_LEVEL)
#define OPL_LOG_INFO(module, ...)                                           \
        {                                                                   \
            tracer_log(LOG_MED_LEVEL, "\x1B[0m[I][%s]", #module);           \
            tracer_log(LOG_MED_LEVEL, __VA_ARGS__);                         \
            tracer_log(LOG_MED_LEVEL, "\r\n");                              \
        }
  • Warn (LOG_MED_LEVEL)
#define OPL_LOG_WARN(module, ...)                                           \
        {                                                                   \
            tracer_log(LOG_MED_LEVEL, "\x1B[33m[W][%s]", #module);          \
            tracer_log(LOG_MED_LEVEL, __VA_ARGS__);                         \
            tracer_log(LOG_MED_LEVEL, "\x1B[0m\r\n");                       \
        }
  • Error (LOG_HIGH_LEVEL)
#define OPL_LOG_ERRO(module, ...)                                           \
        {                                                                   \
            tracer_log(LOG_HIGH_LEVEL, "\x1B[31m[E][%s]", #module);         \
            tracer_log(LOG_HIGH_LEVEL, __VA_ARGS__);                        \
            tracer_log(LOG_HIGH_LEVEL, "\x1B[0m\r\n");                      \
        }

The developer could set what module in the argument module.

Log configuration can also be set according to the log of which module (e.g. BLE Manager log)the developer wants to see in qd_module.h. Module log enable set (1) (e.g. BM_LOG_ENABLED)

#ifndef BM_LOG_ENABLED
#define BM_LOG_ENABLED                          (1)
#endif