Files
linuxSmartie/include/log.h
2026-07-01 01:50:02 +02:00

40 lines
1.4 KiB
C++

#ifndef LINUXSMARTIE_LOG_H
#define LINUXSMARTIE_LOG_H
/* ── kill switch ────────────────────────────────────────────────────────── */
/* comment out to disable all logging */
#define APPLOG_ENABLED
/* comment out to disable file logging */
/* #define LOG_FILE_LOCATION "linuxSmartie.log.gz" */
/* ─────────────────────────────────────────────────────────────────────── */
#ifdef APPLOG_ENABLED
typedef enum {
LOG_INF,
LOG_WRN,
LOG_ERR,
LOG_DBG,
LOG_START,
} log_level_t;
/* __PRETTY_FUNCTION__ is a GCC/Clang extension that gives the full
signature: "voi*d foo(int x)" — same thing source_location gave you.
Falls back to plain __func__ (C99) if somehow unavailable. */
#define applog(level, fmt, ...) \
log_write(level, __func__, fmt, ##__VA_ARGS__)
/* format attribute gives compile-time printf format checking —
better than wha*t std::format gave you at runtime */
void log_write(log_level_t level, const char *func, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
#else /* APPLOG_ENABLED not defined */
#define applog(...) ((void)0)
#endif /* APPLOG_ENABLED */
#endif /* LINUXSMARTIE_LOG_H */