Jeremy Kerr | 3d36ee2 | 2019-05-30 11:15:37 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 2 | |
| 3 | #ifndef _LIBMCTP_LOG_H |
| 4 | #define _LIBMCTP_LOG_H |
| 5 | |
| 6 | /* libmctp-internal logging */ |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 7 | |
Matt Johnston | 1250727 | 2024-10-01 12:17:19 +0800 | [diff] [blame] | 8 | #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 |
| 15 | mctp_prlog(int level __unused, const char *fmt __unused, ...) |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | #else |
| 20 | |
Jeremy Kerr | c7e764a | 2019-05-28 16:49:03 +0800 | [diff] [blame] | 21 | void mctp_prlog(int level, const char *fmt, ...) |
Jeremy Kerr | 5134f0e | 2019-03-06 09:10:43 +0800 | [diff] [blame] | 22 | __attribute__((format(printf, 2, 3))); |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 23 | |
Matt Johnston | 1250727 | 2024-10-01 12:17:19 +0800 | [diff] [blame] | 24 | #endif |
| 25 | |
Andrew Jeffery | 6f3630d | 2020-05-22 16:05:58 +0930 | [diff] [blame] | 26 | #ifndef pr_fmt |
| 27 | #define pr_fmt(x) x |
| 28 | #endif |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 29 | |
Andrew Jeffery | 6f3630d | 2020-05-22 16:05:58 +0930 | [diff] [blame] | 30 | #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 Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 38 | |
| 39 | #endif /* _LIBMCTP_LOG_H */ |