1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 3 #ifndef _LIBMCTP_LOG_H 4 #define _LIBMCTP_LOG_H 5 6 /* libmctp-internal logging */ 7 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 21 void mctp_prlog(int level, const char *fmt, ...) 22 __attribute__((format(printf, 2, 3))); 23 24 #endif 25 26 #ifndef pr_fmt 27 #define pr_fmt(x) x 28 #endif 29 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__) 38 39 #endif /* _LIBMCTP_LOG_H */ 40