blob: d2b5899280915487e3b14923c9056b0a3d29d97a [file] [log] [blame]
Jeremy Kerr3d36ee22019-05-30 11:15:37 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
Jeremy Kerr4cdc2002019-02-07 16:49:12 +08002
3#ifndef _LIBMCTP_LOG_H
4#define _LIBMCTP_LOG_H
5
6/* libmctp-internal logging */
Jeremy Kerr4cdc2002019-02-07 16:49:12 +08007
Matt Johnston12507272024-10-01 12:17:19 +08008#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
12#ifdef MCTP_NOLOG
13
14__attribute__((format(printf, 2, 3))) static inline void
15mctp_prlog(int level __unused, const char *fmt __unused, ...)
16{
17}
18
19#else
20
Jeremy Kerrc7e764a2019-05-28 16:49:03 +080021void mctp_prlog(int level, const char *fmt, ...)
Jeremy Kerr5134f0e2019-03-06 09:10:43 +080022 __attribute__((format(printf, 2, 3)));
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080023
Matt Johnston12507272024-10-01 12:17:19 +080024#endif
25
Andrew Jeffery6f3630d2020-05-22 16:05:58 +093026#ifndef pr_fmt
27#define pr_fmt(x) x
28#endif
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080029
Andrew Jeffery6f3630d2020-05-22 16:05:58 +093030#define mctp_prerr(fmt, ...) \
31 mctp_prlog(MCTP_LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
32#define mctp_prwarn(fmt, ...) \
33 mctp_prlog(MCTP_LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
34#define mctp_prinfo(fmt, ...) \
35 mctp_prlog(MCTP_LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
36#define mctp_prdebug(fmt, ...) \
37 mctp_prlog(MCTP_LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080038
39#endif /* _LIBMCTP_LOG_H */