ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/src/utility/duer_log.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | // Copyright (2017) Baidu Inc. All rights reserved. |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | * File: duer_log.h |
| TMBOY | 47:9e361da97763 | 4 | * Auth: Su Hao(suhao@baidu.com) |
| TMBOY | 47:9e361da97763 | 5 | * Desc: Print log. |
| TMBOY | 47:9e361da97763 | 6 | */ |
| TMBOY | 47:9e361da97763 | 7 | |
| TMBOY | 47:9e361da97763 | 8 | #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H |
| TMBOY | 47:9e361da97763 | 9 | #define BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | #include "us_ticker_api.h" |
| TMBOY | 47:9e361da97763 | 12 | |
| TMBOY | 47:9e361da97763 | 13 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 14 | extern "C" { |
| TMBOY | 47:9e361da97763 | 15 | #endif |
| TMBOY | 47:9e361da97763 | 16 | |
| TMBOY | 47:9e361da97763 | 17 | #ifndef DUER_LOG_LEVEL |
| TMBOY | 47:9e361da97763 | 18 | #define DUER_LOG_LEVEL (3) |
| TMBOY | 47:9e361da97763 | 19 | #endif |
| TMBOY | 47:9e361da97763 | 20 | |
| TMBOY | 47:9e361da97763 | 21 | #if defined(DUER_LOG_LEVEL) |
| TMBOY | 47:9e361da97763 | 22 | #define DUER_LOG(_level, ...) \ |
| TMBOY | 47:9e361da97763 | 23 | printf("[%s][%lu] %s(%d): ", _level, us_ticker_read(), __FILE__, __LINE__), \ |
| TMBOY | 47:9e361da97763 | 24 | printf(__VA_ARGS__), \ |
| TMBOY | 47:9e361da97763 | 25 | printf("\n") |
| TMBOY | 47:9e361da97763 | 26 | #endif |
| TMBOY | 47:9e361da97763 | 27 | |
| TMBOY | 47:9e361da97763 | 28 | #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 5) |
| TMBOY | 47:9e361da97763 | 29 | #define DUER_LOGV(...) DUER_LOG("V", __VA_ARGS__) |
| TMBOY | 47:9e361da97763 | 30 | #else |
| TMBOY | 47:9e361da97763 | 31 | #define DUER_LOGV(...) |
| TMBOY | 47:9e361da97763 | 32 | #endif |
| TMBOY | 47:9e361da97763 | 33 | |
| TMBOY | 47:9e361da97763 | 34 | #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 4) |
| TMBOY | 47:9e361da97763 | 35 | #define DUER_LOGD(...) DUER_LOG("D", __VA_ARGS__) |
| TMBOY | 47:9e361da97763 | 36 | #else |
| TMBOY | 47:9e361da97763 | 37 | #define DUER_LOGD(...) |
| TMBOY | 47:9e361da97763 | 38 | #endif |
| TMBOY | 47:9e361da97763 | 39 | |
| TMBOY | 47:9e361da97763 | 40 | #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 3) |
| TMBOY | 47:9e361da97763 | 41 | #define DUER_LOGI(...) DUER_LOG("I", __VA_ARGS__) |
| TMBOY | 47:9e361da97763 | 42 | #else |
| TMBOY | 47:9e361da97763 | 43 | #define DUER_LOGI(...) |
| TMBOY | 47:9e361da97763 | 44 | #endif |
| TMBOY | 47:9e361da97763 | 45 | |
| TMBOY | 47:9e361da97763 | 46 | #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 2) |
| TMBOY | 47:9e361da97763 | 47 | #define DUER_LOGW(...) DUER_LOG("W", __VA_ARGS__) |
| TMBOY | 47:9e361da97763 | 48 | #else |
| TMBOY | 47:9e361da97763 | 49 | #define DUER_LOGW(...) |
| TMBOY | 47:9e361da97763 | 50 | #endif |
| TMBOY | 47:9e361da97763 | 51 | |
| TMBOY | 47:9e361da97763 | 52 | #if defined(DUER_LOG_LEVEL) && (DUER_LOG_LEVEL >= 1) |
| TMBOY | 47:9e361da97763 | 53 | #define DUER_LOGE(...) DUER_LOG("E", __VA_ARGS__) |
| TMBOY | 47:9e361da97763 | 54 | #else |
| TMBOY | 47:9e361da97763 | 55 | #define DUER_LOGE(...) |
| TMBOY | 47:9e361da97763 | 56 | #endif |
| TMBOY | 47:9e361da97763 | 57 | |
| TMBOY | 47:9e361da97763 | 58 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 59 | } |
| TMBOY | 47:9e361da97763 | 60 | #endif |
| TMBOY | 47:9e361da97763 | 61 | |
| TMBOY | 47:9e361da97763 | 62 | #endif/*BAIDU_IOT_TINYDU_IOT_OS_SRC_UTILITY_DUER_LOG_H*/ |
