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