ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers duer_log.h Source File

duer_log.h

00001 // Copyright (2017) Baidu Inc. All rights reserved.
00002 /**
00003  * File: duer_log.h
00004  * Auth: Su Hao(suhao@baidu.com)
00005  * Desc: Print log.
00006  */
00007 
00008 #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H
00009 #define BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H
00010 
00011 #include "us_ticker_api.h"
00012 
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016 
00017 #ifndef DUER_LOG_LEVEL
00018 #define DUER_LOG_LEVEL (3)
00019 #endif
00020 
00021 #if defined(DUER_LOG_LEVEL)
00022 #define DUER_LOG(_level, ...)     \
00023     printf("[%s][%lu] %s(%d): ", _level, us_ticker_read(), __FILE__, __LINE__), \
00024     printf(__VA_ARGS__), \
00025     printf("\n")
00026 #endif
00027 
00028 #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 5)
00029 #define DUER_LOGV(...)            DUER_LOG("V", __VA_ARGS__)
00030 #else
00031 #define DUER_LOGV(...)
00032 #endif
00033 
00034 #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 4)
00035 #define DUER_LOGD(...)            DUER_LOG("D", __VA_ARGS__)
00036 #else
00037 #define DUER_LOGD(...)
00038 #endif
00039 
00040 #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 3)
00041 #define DUER_LOGI(...)            DUER_LOG("I", __VA_ARGS__)
00042 #else
00043 #define DUER_LOGI(...)
00044 #endif
00045 
00046 #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 2)
00047 #define DUER_LOGW(...)            DUER_LOG("W", __VA_ARGS__)
00048 #else
00049 #define DUER_LOGW(...)
00050 #endif
00051 
00052 #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 1)
00053 #define DUER_LOGE(...)            DUER_LOG("E", __VA_ARGS__)
00054 #else
00055 #define DUER_LOGE(...)
00056 #endif
00057 
00058 #ifdef __cplusplus
00059 }
00060 #endif
00061 
00062 #endif/*BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H*/