Added timestamps and logging
This commit is contained in:
+22
-13
@@ -43,7 +43,7 @@
|
||||
#include <string.h>
|
||||
#include <linux/prctl.h>
|
||||
#include "common/config/config_userapi.h"
|
||||
|
||||
#include <time.h>
|
||||
// main log variables
|
||||
|
||||
log_mem_cnt_t log_mem_d[2];
|
||||
@@ -476,20 +476,29 @@ char *log_getthreadname(char *threadname,
|
||||
}
|
||||
|
||||
static int log_header(char *log_buffer,
|
||||
int buffsize,
|
||||
int comp,
|
||||
int level,
|
||||
const char *format)
|
||||
int buffsize,
|
||||
int comp,
|
||||
int level,
|
||||
const char *format)
|
||||
{
|
||||
char threadname[PR_SET_NAME];
|
||||
return snprintf(log_buffer, buffsize, "%s%s[%s]%c %s %s%s",
|
||||
log_level_highlight_end[level],
|
||||
( (g_log->flag & FLAG_NOCOLOR)?"":log_level_highlight_start[level]),
|
||||
g_log->log_component[comp].name,
|
||||
( (g_log->flag & FLAG_LEVEL)?g_log->level2string[level]:' '),
|
||||
( (g_log->flag & FLAG_THREAD)?log_getthreadname(threadname,PR_SET_NAME+1):""),
|
||||
format,
|
||||
log_level_highlight_end[level]);
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
struct tm tm;
|
||||
localtime_r(&tv.tv_sec, &tm);
|
||||
|
||||
return snprintf(log_buffer, buffsize, "%02d:%02d:%02d.%06ld %s%s[%s]%c %s %s%s",
|
||||
tm.tm_hour,
|
||||
tm.tm_min,
|
||||
tm.tm_sec,
|
||||
tv.tv_usec,
|
||||
log_level_highlight_end[level],
|
||||
((g_log->flag & FLAG_NOCOLOR) ? "" : log_level_highlight_start[level]),
|
||||
g_log->log_component[comp].name,
|
||||
((g_log->flag & FLAG_LEVEL) ? g_log->level2string[level] : ' '),
|
||||
((g_log->flag & FLAG_THREAD) ? log_getthreadname(threadname, PR_SET_NAME + 1) : ""),
|
||||
format,
|
||||
log_level_highlight_end[level]);
|
||||
}
|
||||
|
||||
void logRecord_mt(const char *file,
|
||||
|
||||
Reference in New Issue
Block a user