Commit 9eea072f authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by rojer

Add optional log of timestamp difference

    PUBLISHED_FROM=046ac695f1c771ab156bdd950a8d5cbecbf65bfa
parent aa2ff674
......@@ -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) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment