13#define __ERR(fmt, ...) log_fatal(fmt "%s", __VA_ARGS__)
22 __ERR(__VA_ARGS__, ""); \
32#define ASSERT_S(expr, msg) \
36 "\n\tAssert Failed", \
37 ANSI_FG_RED) ":\t%s\n\t" ANSICOLOR("Expected", \
53#define VASSERT_S(expr, fmt, ...) \
56 ERR(ANSICOLOR("\n\tAssert Failed", \
57 ANSI_FG_RED) ":\t" fmt \
59 "Expected", ANSI_FG_RED) ":\t %s", \
60 __VA_ARGS__, #expr); \
66#define ANSICOLOR(str, color) "\x1b[" color "m" str "\x1b[0m"
68#define ANSICOLOR(str, color) str
71#define ANSI_FG_BLACK "30"
72#define ANSI_FG_RED "31"
73#define ANSI_FG_GREEN "32"
74#define ANSI_FG_YELLOW "33"
75#define ANSI_FG_BLUE "34"
76#define ANSI_FG_MAGENTA "35"
77#define ANSI_FG_CYAN "36"
78#define ANSI_FG_WHITE "37"
79#define ANSI_FG_GRAY "90"
80#define ANSI_FG_BRIGHT_RED "91"
81#define ANSI_FG_BRIGHT_GREEN "92"
82#define ANSI_FG_BRIGHT_YELLOW "93"
83#define ANSI_FG_BRIGHT_BLUE "94"
84#define ANSI_FG_BRIGHT_MAGENTA "95"
85#define ANSI_FG_BRIGHT_CYAN "96"
86#define ANSI_FG_BRIGHT_WHITE "97"
88#define ANSI_BG_BLACK "40"
89#define ANSI_BG_RED "41"
90#define ANSI_BG_GREEN "42"
91#define ANSI_BG_YELLOW "43"
92#define ANSI_BG_BLUE "44"
93#define ANSI_BG_MAGENTA "45"
94#define ANSI_BG_CYAN "46"
95#define ANSI_BG_WHITE "47"
96#define ANSI_BG_GRAY "100"
97#define ANSI_BG_BRIGHT_RED "101"
98#define ANSI_BG_BRIGHT_GREEN "102"
99#define ANSI_BG_BRIGHT_YELLOW "103"
100#define ANSI_BG_BRIGHT_BLUE "104"
101#define ANSI_BG_BRIGHT_MAGENTA "105"
102#define ANSI_BG_BRIGHT_CYAN "106"
103#define ANSI_BG_BRIGHT_WHITE "107"
127#define logconf_trace(conf, ...) \
128 logconf_log(conf, LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
135#define logconf_debug(conf, ...) \
136 logconf_log(conf, LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
143#define logconf_info(conf, ...) \
144 logconf_log(conf, LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
151#define logconf_warn(conf, ...) \
152 logconf_log(conf, LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
159#define logconf_error(conf, ...) \
160 logconf_log(conf, LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
167#define logconf_fatal(conf, ...) \
168 logconf_log(conf, LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
171#define __logconf_log(conf, level, file, line, fmt, ...) \
172 _log_log((conf)->L, level, file, line, "[%s] " fmt "%s", (conf)->id, \
183#define logconf_log(conf, level, file, line, ...) \
184 if (!(conf)->is_disabled) \
185 __logconf_log(conf, level, file, line, __VA_ARGS__, "")
188#define LOGCONF_ID_LEN 64 + 1
#define PRINTF_LIKE(a, b)
Definition: attributes.h:4
void(* log_LogFn)(log_Event *ev)
Definition: log.h:29
void(* log_LockFn)(bool lock, void *udata)
Definition: log.h:30
void logconf_cleanup(struct logconf *conf)
Cleanup a struct logconf module.
void logconf_setup(struct logconf *conf, const char id[], FILE *fp)
Initialize a struct logconf module from a config file.
int logconf_add_fp(struct logconf *conf, FILE *fp, int level)
File where the log will be written.
void logconf_branch(struct logconf *branch, struct logconf *orig, const char id[])
Branch and link a struct logconf module to a existing one.
void logconf_set_quiet(struct logconf *conf, bool enable)
Toggle quiet mode.
void logconf_set_level(struct logconf *conf, int level)
Set the current logging level.
#define LOGCONF_ID_LEN
Definition: logconf.h:188
void logconf_add_callback(struct logconf *conf, log_LogFn fn, void *udata, int level)
Callback functions called when logging data.
void logconf_http(struct logconf *conf, struct loginfo *info, char url[], struct logconf_szbuf header, struct logconf_szbuf body, char label_fmt[],...)
Log HTTP transfers.
void logconf_set_lock(struct logconf *conf, log_LockFn fn, void *udata)
If the log will be written to from multiple threads a lock function can be set.
struct logconf_field logconf_get_field(struct logconf *conf, char *const path[], unsigned depth)
Get the value from a given JSON field of the config file.
The read-only config.json field.
Definition: logconf.h:194
const char * start
Definition: logconf.h:196
size_t size
Definition: logconf.h:198
Generic sized-buffer.
Definition: logconf.h:202
char * start
Definition: logconf.h:204
size_t size
Definition: logconf.h:206
A stackful and modularized wrapper over the popular 'log.c' facilities.
Definition: logconf.h:217
char * fname
Definition: logconf.h:236
FILE * f
Definition: logconf.h:238
int * counter
Definition: logconf.h:230
log_Logger * L
Definition: logconf.h:232
char ** ids
Definition: logconf.h:244
size_t size
Definition: logconf.h:243
_Bool is_branch
Definition: logconf.h:223
_Bool is_disabled
Definition: logconf.h:225
struct logconf_szbuf file
Definition: logconf.h:227
struct logconf::@13 * logger
struct logconf::@14 disable_modules
unsigned pid
Definition: logconf.h:221
struct logconf::@13 * http
Store logging information from log_http()
Definition: logconf.h:249
size_t counter
Definition: logconf.h:251
uint64_t tstamp_ms
Definition: logconf.h:253