blob: e24738a9252de3954a8a5c91e1d9378762d616b1 [file] [log] [blame]
Jeremy Kerr4cdc2002019-02-07 16:49:12 +08001/* SPDX-License-Identifier: Apache-2.0 */
2
3#ifndef _LIBMCTP_LOG_H
4#define _LIBMCTP_LOG_H
5
6/* libmctp-internal logging */
7#ifndef pr_fmt
8#define pr_fmt
9#endif
10
11#if defined(MCTP_LOG_STDERR)
12
13#include <stdio.h>
14
15#define MCTP_LOG_ERR 0
16#define MCTP_LOG_WARNING 0
17#define MCTP_LOG_NOTICE 0
18#define MCTP_LOG_INFO 0
19#define MCTP_LOG_DEBUG 0
20
21#define mctp_prlog(x, fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
22
23#elif defined(MCTP_LOG_SYSLOG)
24
25#include <syslog.h>
26
27#define MCTP_LOG_ERR LOG_ERR
28#define MCTP_LOG_WARNING LOG_WARNING
29#define MCTP_LOG_NOTICE LOG_NOTICE
30#define MCTP_LOG_INFO LOG_INFO
31#define MCTP_LOG_DEBUG LOG_DEBUG
32
33#define mctp_prlog(x, fmt, ...) syslog(x, fmt, ##__VA_ARGS__)
34
35#elif defined(MCTP_LOG_CUSTOM)
36
37#include <config.h>
38
39#if !defined(mctp_prlog)
40#error Custom logging implementation enabled, but no definition for mctp_prlog
41#endif
42
43
44#else
45#error No log implementation found
46#endif
47
48#define mctp_prerr(fmt, ...) mctp_prlog(MCTP_LOG_ERR, fmt, ##__VA_ARGS__)
49#define mctp_prwarn(fmt, ...) mctp_prlog(MCTP_LOG_WARNING, fmt, ##__VA_ARGS__)
50#define mctp_prinfo(fmt, ...) mctp_prlog(MCTP_LOG_INFO, fmt, ##__VA_ARGS__)
51#define mctp_prdebug(fmt, ...) mctp_prlog(MCTP_LOG_DEBUG, fmt, ##__VA_ARGS__)
52
53
54#endif /* _LIBMCTP_LOG_H */