blob: b8bee70d3c68eb5749a4b23b296a444dbb20d124 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#pragma once
2
3#include <syslog.h>
4
5void mdlog_init(int level, int write_syslog);
6
7void mdlog_printf(int log_prio, const char *fmt, ...);
8
9void 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