#include <time.h>
#include <unistd.h>
#include <stdarg.h>
-#include "process.h"
+#include <pthread.h>
+#include "process.h"
#include "debug.h"
const char red_color[] = {
0x1b, 0x5b, 0x30, 0x3b, 0x33, 0x37, 0x3b, 0x34, 0x30, 0x6d, 0x0,
};
-int trace_level = 1;
-int logfile_fd = STDERR_FILENO;
+int trace_level = TRACE_INFO;
+static int logfile_fd = STDERR_FILENO;
static const char *assign_color(int color)
{
case 2:
return green_color;
default:
- return normal_color;
+ return normal_color;
}
}
char time[32];
char trace[1024];
char all_trace[1538];
+ char thread_name[16];
const char *color_str = assign_color(color);
int ret;
strftime(time, sizeof(time), "%d.%m.%Y %T", localtime(&t));
+ pthread_getname_np(pthread_self(), thread_name, sizeof(thread_name));
+
ret = snprintf(all_trace, sizeof(all_trace),
- "%s%s [%5d.%d] %s:%d %s %s",
+ "%s%s [%s] %s:%d %s %s",
color_str, time,
- getpid(), get_parent_count(),
+ thread_name,
file, line, normal_color, trace);
ret = write(logfile_fd, all_trace, ret);