mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-16 23:30:39 +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 <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Amalgamated: #include "common/cs_time.h" */
|
||||||
|
|
||||||
enum cs_log_level s_cs_log_level =
|
enum cs_log_level s_cs_log_level =
|
||||||
#ifdef CS_ENABLE_DEBUG
|
#ifdef CS_ENABLE_DEBUG
|
||||||
LL_VERBOSE_DEBUG;
|
LL_VERBOSE_DEBUG;
|
||||||
@ -346,19 +348,33 @@ enum cs_log_level s_cs_log_level =
|
|||||||
LL_ERROR;
|
LL_ERROR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CS_LOG_TS_DIFF
|
||||||
|
double cs_log_ts;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CS_DISABLE_STDIO
|
#ifndef CS_DISABLE_STDIO
|
||||||
void cs_log_printf(const char *fmt, ...) {
|
void cs_log_printf(const char *fmt, ...) {
|
||||||
va_list ap;
|
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);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
#ifdef CS_LOG_TS_DIFF
|
||||||
|
cs_log_ts = now;
|
||||||
|
#endif
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
#endif /* !CS_DISABLE_STDIO */
|
#endif /* !CS_DISABLE_STDIO */
|
||||||
|
|
||||||
void cs_log_set_level(enum cs_log_level level) {
|
void cs_log_set_level(enum cs_log_level level) {
|
||||||
s_cs_log_level = level;
|
s_cs_log_level = level;
|
||||||
|
#ifdef CS_LOG_TS_DIFF
|
||||||
|
cs_log_ts = cs_time();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef MG_MODULE_LINES
|
#ifdef MG_MODULE_LINES
|
||||||
#line 0 "./src/../../common/cs_dirent.c"
|
#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
|
#ifndef CS_DISABLE_STDIO
|
||||||
|
|
||||||
|
#ifdef CS_LOG_TS_DIFF
|
||||||
|
extern double cs_log_ts;
|
||||||
|
#endif
|
||||||
|
|
||||||
void cs_log_printf(const char *fmt, ...);
|
void cs_log_printf(const char *fmt, ...);
|
||||||
|
|
||||||
#define LOG(l, x) \
|
#define LOG(l, x) \
|
||||||
|
Loading…
Reference in New Issue
Block a user