Skip to content
This repository was archived by the owner on Jul 14, 2019. It is now read-only.

Commit aebef60

Browse files
author
Lior Amram
committed
logger: output context
1 parent d35f3f0 commit aebef60

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/logger.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,13 @@
1919
*/
2020
#include "logger.h"
2121
#include "vmbuf.h"
22+
#include "context.h"
2223
#include <string.h>
2324
#include <stdio.h>
2425
#include <sys/types.h>
2526
#include <sys/stat.h>
2627
#include <sys/time.h>
2728
#include <fcntl.h>
28-
/*
29-
TODO: move to daemonize or somewhere else...
30-
int logger_create(const char *logfile) {
31-
if (NULL == logfile)
32-
return -1;
33-
int fd = -1;
34-
if (logfile[0] == '|') {
35-
// popen
36-
++logfile;
37-
FILE *fp = popen(logfile, "w");
38-
if (NULL != fp)
39-
fd = fileno(fp);
40-
} else {
41-
// open
42-
fd = open(logfile, O_CREAT | O_WRONLY | O_APPEND, 0644);
43-
}
44-
return fd;
45-
}
46-
*/
4729

4830
static const char *MC_INFO = "INFO ";
4931
static const char *MC_ERROR = "ERROR";
@@ -59,7 +41,7 @@ static void begin_log_line(const char *msg_class) {
5941
usec = tv.tv_usec;
6042
vmbuf_init(&log_buf, 4096);
6143
vmbuf_strftime(&log_buf, "%Y-%m-%d %H:%M:%S", tmp);
62-
vmbuf_sprintf(&log_buf, ".%03jd.%03jd %d %s ", usec / 1000, usec % 1000, getpid(), msg_class);
44+
vmbuf_sprintf(&log_buf, ".%03jd.%03jd %d %p %s ", usec / 1000, usec % 1000, getpid(), current_ctx, msg_class);
6345
}
6446

6547
static inline void end_log_line(int fd) {

0 commit comments

Comments
 (0)