rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include <syslog.h> |
| 4 | |
| 5 | void mdlog_init(int level, int write_syslog); |
| 6 | |
| 7 | void mdlog_printf(int log_prio, const char *fmt, ...); |
| 8 | |
| 9 | void error(const char *msg, ...) __attribute__((noreturn)); |
| 10 | |
| 11 | /* LOG macro support */ |
| 12 | #define DEBUG_BY_CONSOLE |
| 13 | #include <stdio.h> |
| 14 | #if defined(DEBUG_BY_CONSOLE) |
| 15 | #define MD_LOGV(...) printf(__VA_ARGS__) |
| 16 | #define MD_LOGD(...) printf(__VA_ARGS__) |
| 17 | #define MD_LOGI(...) printf(__VA_ARGS__) |
| 18 | #define MD_LOGW(...) printf(__VA_ARGS__) |
| 19 | #define MD_LOGE(...) printf(__VA_ARGS__) |
| 20 | #else |
| 21 | #define MD_LOGV(...) mdlog_printf(LOG_DEBUG, __VA_ARGS__) |
| 22 | #define MD_LOGD(...) mdlog_printf(LOG_DEBUG, __VA_ARGS__) |
| 23 | #define MD_LOGI(...) mdlog_printf(LOG_INFO, __VA_ARGS__) |
| 24 | #define MD_LOGW(...) mdlog_printf(LOG_WARNING, __VA_ARGS__) |
| 25 | #define MD_LOGE(...) mdlog_printf(LOG_ERR, __VA_ARGS__) |
| 26 | #endif |