mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-28 05:39:00 +08:00
Add optional log of timestamp difference
PUBLISHED_FROM=046ac695f1c771ab156bdd950a8d5cbecbf65bfa
This commit is contained in:
parent
aa2ff674db
commit
9eea072f2a
16
mongoose.c
16
mongoose.c
@ -339,6 +339,8 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst) {
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Amalgamated: #include "common/cs_time.h" */
|
||||
|
||||
enum cs_log_level s_cs_log_level =
|
||||
#ifdef CS_ENABLE_DEBUG
|
||||
LL_VERBOSE_DEBUG;
|
||||
@ -346,19 +348,33 @@ enum cs_log_level s_cs_log_level =
|
||||
LL_ERROR;
|
||||
#endif
|
||||
|
||||
#ifdef CS_LOG_TS_DIFF
|
||||
double cs_log_ts;
|
||||
#endif
|
||||
|
||||
#ifndef CS_DISABLE_STDIO
|
||||
void cs_log_printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
#ifdef CS_LOG_TS_DIFF
|
||||
double now = cs_time();
|
||||
fprintf(stderr, "%7u ", (unsigned int) ((now - cs_log_ts) * 1000000));
|
||||
#endif
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
#ifdef CS_LOG_TS_DIFF
|
||||
cs_log_ts = now;
|
||||
#endif
|
||||
fflush(stderr);
|
||||
}
|
||||
#endif /* !CS_DISABLE_STDIO */
|
||||
|
||||
void cs_log_set_level(enum cs_log_level level) {
|
||||
s_cs_log_level = level;
|
||||
#ifdef CS_LOG_TS_DIFF
|
||||
cs_log_ts = cs_time();
|
||||
#endif
|
||||
}
|
||||
#ifdef MG_MODULE_LINES
|
||||
#line 0 "./src/../../common/cs_dirent.c"
|
||||
|
@ -565,6 +565,10 @@ void cs_log_set_level(enum cs_log_level level);
|
||||
|
||||
#ifndef CS_DISABLE_STDIO
|
||||
|
||||
#ifdef CS_LOG_TS_DIFF
|
||||
extern double cs_log_ts;
|
||||
#endif
|
||||
|
||||
void cs_log_printf(const char *fmt, ...);
|
||||
|
||||
#define LOG(l, x) \
|
||||
|
Loading…
Reference in New Issue
Block a user