we're getttng C to work
C deez nuts
This commit is contained in:
41
include/log.h
Normal file
41
include/log.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef LOG_H
|
||||
#define 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
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef enum {
|
||||
LOG_INF,
|
||||
LOG_WRN,
|
||||
LOG_ERR,
|
||||
LOG_DBG,
|
||||
LOG_START,
|
||||
} LogLevel;
|
||||
|
||||
/* __PRETTY_FUNCTION__ is a GCC/Clang extension that gives the full
|
||||
s ignature: "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, __PRETTY_FUNCTION__, fmt, ##__VA_ARGS__)
|
||||
|
||||
/* format attribute gives compile-time printf format checking —
|
||||
better than wha*t std::format gave you at runtime */
|
||||
void log_write(LogLevel 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 /* LOG_H */
|
||||
Reference in New Issue
Block a user