mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-29 16:25:54 +08:00
eaef5bd133
This reverts commit 1a17e17c462bdd4e1d26d8742f8b7087273e04c2. PUBLISHED_FROM=80028de308c9a021955d1425d2bfee8feb85f193
79 lines
1.3 KiB
C
79 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2014-2016 Cesanta Software Limited
|
|
* All rights reserved
|
|
*/
|
|
|
|
#ifndef CS_COMMON_CS_DBG_H_
|
|
#define CS_COMMON_CS_DBG_H_
|
|
|
|
#if CS_ENABLE_STDIO
|
|
#include <stdio.h>
|
|
#endif
|
|
|
|
#ifndef CS_ENABLE_DEBUG
|
|
#define CS_ENABLE_DEBUG 0
|
|
#endif
|
|
|
|
#ifndef CS_LOG_ENABLE_TS_DIFF
|
|
#define CS_LOG_ENABLE_TS_DIFF 0
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
enum cs_log_level {
|
|
LL_NONE = -1,
|
|
LL_ERROR = 0,
|
|
LL_WARN = 1,
|
|
LL_INFO = 2,
|
|
LL_DEBUG = 3,
|
|
LL_VERBOSE_DEBUG = 4,
|
|
|
|
_LL_MIN = -2,
|
|
_LL_MAX = 5,
|
|
};
|
|
|
|
void cs_log_set_level(enum cs_log_level level);
|
|
|
|
#if CS_ENABLE_STDIO
|
|
|
|
void cs_log_set_file(FILE *file);
|
|
|
|
extern enum cs_log_level cs_log_level;
|
|
void cs_log_print_prefix(const char *func);
|
|
void cs_log_printf(const char *fmt, ...);
|
|
|
|
#define LOG(l, x) \
|
|
if (cs_log_level >= l) { \
|
|
cs_log_print_prefix(__func__); \
|
|
cs_log_printf x; \
|
|
}
|
|
|
|
#ifndef CS_NDEBUG
|
|
|
|
#define DBG(x) \
|
|
if (cs_log_level >= LL_VERBOSE_DEBUG) { \
|
|
cs_log_print_prefix(__func__); \
|
|
cs_log_printf x; \
|
|
}
|
|
|
|
#else /* NDEBUG */
|
|
|
|
#define DBG(x)
|
|
|
|
#endif
|
|
|
|
#else /* CS_ENABLE_STDIO */
|
|
|
|
#define LOG(l, x)
|
|
#define DBG(x)
|
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* CS_COMMON_CS_DBG_H_ */
|