Many different threads might be calling the same functions
concurrently. Add the name of the thread so that it becomes more
obvious which thread is emitting the given print.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
#include <time.h>
#include <unistd.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include <stdarg.h>
#include "debug.h"
const char red_color[] = {
#include "debug.h"
const char red_color[] = {
char time[32];
char trace[1024];
char all_trace[1538];
char time[32];
char trace[1024];
char all_trace[1538];
const char *color_str = assign_color(color);
int ret;
const char *color_str = assign_color(color);
int ret;
strftime(time, sizeof(time), "%d.%m.%Y %T", localtime(&t));
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),
ret = snprintf(all_trace, sizeof(all_trace),
- "%s%s [%5d.%d] %s:%d %s %s",
+ "%s%s [%5d.%d] %s %s:%d %s %s",
color_str, time,
getpid(), get_parent_count(),
color_str, time,
getpid(), get_parent_count(),
file, line, normal_color, trace);
ret = write(logfile_fd, all_trace, ret);
file, line, normal_color, trace);
ret = write(logfile_fd, all_trace, ret);