12#define __ERR(fmt, ...) log_fatal(fmt "%s", __VA_ARGS__)
21 __ERR(__VA_ARGS__, ""); \
31#define ASSERT_S(expr, msg) \
35 "\n\tAssert Failed", \
36 ANSI_FG_RED) ":\t%s\n\t" ANSICOLOR("Expected", \
52#define VASSERT_S(expr, fmt, ...) \
55 ERR(ANSICOLOR("\n\tAssert Failed", \
56 ANSI_FG_RED) ":\t" fmt \
58 "Expected", ANSI_FG_RED) ":\t %s", \
59 __VA_ARGS__, #expr); \
65#define ANSICOLOR(str, color) "\x1b[" color "m" str "\x1b[0m"
67#define ANSICOLOR(str, color) str
70#define ANSI_FG_BLACK "30"
71#define ANSI_FG_RED "31"
72#define ANSI_FG_GREEN "32"
73#define ANSI_FG_YELLOW "33"
74#define ANSI_FG_BLUE "34"
75#define ANSI_FG_MAGENTA "35"
76#define ANSI_FG_CYAN "36"
77#define ANSI_FG_WHITE "37"
78#define ANSI_FG_GRAY "90"
79#define ANSI_FG_BRIGHT_RED "91"
80#define ANSI_FG_BRIGHT_GREEN "92"
81#define ANSI_FG_BRIGHT_YELLOW "93"
82#define ANSI_FG_BRIGHT_BLUE "94"
83#define ANSI_FG_BRIGHT_MAGENTA "95"
84#define ANSI_FG_BRIGHT_CYAN "96"
85#define ANSI_FG_BRIGHT_WHITE "97"
87#define ANSI_BG_BLACK "40"
88#define ANSI_BG_RED "41"
89#define ANSI_BG_GREEN "42"
90#define ANSI_BG_YELLOW "43"
91#define ANSI_BG_BLUE "44"
92#define ANSI_BG_MAGENTA "45"
93#define ANSI_BG_CYAN "46"
94#define ANSI_BG_WHITE "47"
95#define ANSI_BG_GRAY "100"
96#define ANSI_BG_BRIGHT_RED "101"
97#define ANSI_BG_BRIGHT_GREEN "102"
98#define ANSI_BG_BRIGHT_YELLOW "103"
99#define ANSI_BG_BRIGHT_BLUE "104"
100#define ANSI_BG_BRIGHT_MAGENTA "105"
101#define ANSI_BG_BRIGHT_CYAN "106"
102#define ANSI_BG_BRIGHT_WHITE "107"
126#define logconf_trace(conf, ...) \
127 logconf_log(conf, LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
134#define logconf_debug(conf, ...) \
135 logconf_log(conf, LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
142#define logconf_info(conf, ...) \
143 logconf_log(conf, LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
150#define logconf_warn(conf, ...) \
151 logconf_log(conf, LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
158#define logconf_error(conf, ...) \
159 logconf_log(conf, LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
166#define logconf_fatal(conf, ...) \
167 logconf_log(conf, LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
170#define __logconf_log(conf, level, file, line, fmt, ...) \
171 _log_log((conf)->L, level, file, line, "[%s] " fmt "%s", (conf)->id, \
182#define logconf_log(conf, level, file, line, ...) \
183 if (!(conf)->is_disabled) \
184 __logconf_log(conf, level, file, line, __VA_ARGS__, "")
187#define LOGCONF_ID_LEN 64 + 1
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:187
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:193
const char * start
Definition: logconf.h:195
size_t size
Definition: logconf.h:197
Generic sized-buffer.
Definition: logconf.h:201
char * start
Definition: logconf.h:203
size_t size
Definition: logconf.h:205
A stackful and modularized wrapper over the popular 'log.c' facilities.
Definition: logconf.h:216
char * fname
Definition: logconf.h:235
FILE * f
Definition: logconf.h:237
int * counter
Definition: logconf.h:229
log_Logger * L
Definition: logconf.h:231
char ** ids
Definition: logconf.h:243
size_t size
Definition: logconf.h:242
_Bool is_branch
Definition: logconf.h:222
_Bool is_disabled
Definition: logconf.h:224
struct logconf_szbuf file
Definition: logconf.h:226
struct logconf::@13 * logger
struct logconf::@14 disable_modules
unsigned pid
Definition: logconf.h:220
struct logconf::@13 * http
Store logging information from log_http()
Definition: logconf.h:248
size_t counter
Definition: logconf.h:250
uint64_t tstamp_ms
Definition: logconf.h:252