mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
Refactor - always enable LOG macro. Enhance iolog
This commit is contained in:
1 parent
f6cebf6956
commit
544644e94b
9 files changed
+155
-120
No files matched your search
+14
-7
@@ -562,6 +562,9 @@ struct mg_str {
|
||||
#define MG_NULL_STR \
|
||||
{ NULL, 0 }
|
||||
|
||||
#define MG_C_STR(a) \
|
||||
{ (a), sizeof(a) - 1 }
|
||||
|
||||
// Using macro to avoid shadowing C++ struct constructor, see #1298
|
||||
#define mg_str(s) mg_str_s(s)
|
||||
|
||||
@@ -581,19 +584,23 @@ const char *mg_strstr(const struct mg_str haystack, const struct mg_str needle);
|
||||
|
||||
|
||||
|
||||
enum { LL_NONE, LL_ERROR, LL_INFO, LL_DEBUG, LL_VERBOSE_DEBUG };
|
||||
void mg_log(const char *fmt, ...) PRINTF_LIKE(1, 2);
|
||||
bool mg_log_prefix(int ll, const char *file, int line, const char *fname);
|
||||
void mg_log_set(const char *spec);
|
||||
void mg_log_set_callback(void (*fn)(const void *, size_t, void *), void *param);
|
||||
|
||||
#if MG_ENABLE_LOG
|
||||
#define LOG(level, args) \
|
||||
do { \
|
||||
if (mg_log_prefix((level), __FILE__, __LINE__, __func__)) mg_log args; \
|
||||
} while (0)
|
||||
enum { LL_NONE, LL_ERROR, LL_INFO, LL_DEBUG, LL_VERBOSE_DEBUG };
|
||||
bool mg_log_prefix(int ll, const char *file, int line, const char *fname);
|
||||
void mg_log(const char *fmt, ...) PRINTF_LIKE(1, 2);
|
||||
void mg_log_set(const char *spec);
|
||||
void mg_log_set_callback(void (*fn)(const void *, size_t, void *), void *param);
|
||||
#else
|
||||
#define LOG(level, args) (void) 0
|
||||
#define mg_log_set(x) (void) (x)
|
||||
#define LOG(level, args) \
|
||||
do { \
|
||||
(void) level; \
|
||||
if (0) mg_log args; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user