mirror of
https://github.com/linux-msm/qrtr.git
synced 2025-12-24 22:19:15 +01:00
This prepares us to add log-to-syslog functionality by passing all logging through one place. Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
33 lines
905 B
C
33 lines
905 B
C
#ifndef _QRTR_LOGGING_H_
|
|
#define _QRTR_LOGGING_H_
|
|
|
|
#include <stdlib.h>
|
|
#include <syslog.h>
|
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
|
#define __PRINTF__(fmt, args) __attribute__((format(__printf__, fmt, args)))
|
|
#else
|
|
#define __PRINTF__(fmt, args)
|
|
#endif
|
|
|
|
void qlog_setup(const char *tag);
|
|
|
|
void qlog(int priority, const char *format, ...) __PRINTF__(2, 3);
|
|
|
|
#define LOGW(fmt, ...) qlog(LOG_WARNING, fmt, ##__VA_ARGS__)
|
|
#define PLOGW(fmt, ...) \
|
|
qlog(LOG_WARNING, fmt ": %s", ##__VA_ARGS__, strerror(errno))
|
|
|
|
#define LOGE(fmt, ...) qlog(LOG_ERR, fmt, ##__VA_ARGS__)
|
|
#define PLOGE(fmt, ...) qlog(LOG_ERR, fmt ": %s", ##__VA_ARGS__, strerror(errno))
|
|
#define LOGE_AND_EXIT(fmt, ...) do { \
|
|
qlog(LOG_ERR, fmt, ##__VA_ARGS__); \
|
|
exit(1); \
|
|
} while(0)
|
|
#define PLOGE_AND_EXIT(fmt, ...) do { \
|
|
qlog(LOG_ERR, fmt ": %s", ##__VA_ARGS__, strerror(errno)); \
|
|
exit(1); \
|
|
} while(0)
|
|
|
|
#endif
|