Add mg_log_set_fn(), MG_ENABLE_LOG

This commit is contained in:
Sergey Lyubka committed 2022-06-19 09:04:22 +01:00
1 parent 0b5a00c99a
commit 9760b7c9d6
6 files changed
+69 -11

No files matched your search

+8
View File
@@ -8,11 +8,19 @@ void mg_log(const char *fmt, ...);
bool mg_log_prefix(int ll, const char *file, int line, const char *fname);
void mg_log_set(const char *spec);
void mg_hexdump(const void *buf, size_t len);
void mg_log_set_fn(void (*logfunc)(unsigned char ch));
#if MG_ENABLE_LOG
#define MG_LOG(level, args) \
do { \
if (mg_log_prefix((level), __FILE__, __LINE__, __func__)) mg_log args; \
} while (0)
#else
#define MG_LOG(level, args) \
do { \
if (0) mg_log args; \
} while (0)
#endif
#define MG_ERROR(args) MG_LOG(MG_LL_ERROR, args)
#define MG_INFO(args) MG_LOG(MG_LL_INFO, args)