xref: /openbmc/linux/tools/thermal/lib/log.h (revision bbaf1ff0)
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <daniel.lezcano@linaro.org> */
3 #ifndef __THERMAL_TOOLS_LOG_H
4 #define __THERMAL_TOOLS_LOG_H
5 
6 #include <syslog.h>
7 
8 #ifndef __maybe_unused
9 #define __maybe_unused		__attribute__((__unused__))
10 #endif
11 
12 #define TO_SYSLOG 0x1
13 #define TO_STDOUT 0x2
14 #define TO_STDERR 0x4
15 
16 extern void logit(int level, const char *format, ...);
17 
18 #define DEBUG(fmt, ...)		logit(LOG_DEBUG, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
19 #define INFO(fmt, ...)		logit(LOG_INFO, fmt, ##__VA_ARGS__)
20 #define NOTICE(fmt, ...)	logit(LOG_NOTICE, fmt, ##__VA_ARGS__)
21 #define WARN(fmt, ...)		logit(LOG_WARNING, fmt, ##__VA_ARGS__)
22 #define ERROR(fmt, ...)		logit(LOG_ERR, fmt, ##__VA_ARGS__)
23 #define CRITICAL(fmt, ...)	logit(LOG_CRIT, fmt, ##__VA_ARGS__)
24 #define ALERT(fmt, ...)		logit(LOG_ALERT, fmt, ##__VA_ARGS__)
25 #define EMERG(fmt, ...)		logit(LOG_EMERG, fmt, ##__VA_ARGS__)
26 
27 int log_init(int level, const char *ident, int options);
28 int log_str2level(const char *lvl);
29 void log_exit(void);
30 
31 #endif
32