aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-06-12 01:32:43 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-06-12 01:42:34 +0200
commit9f09e9676d2f95b6ab2c5b7a5c0c64888e4df6b3 (patch)
tree388452a84f3a6e4f2308a39e2649ee54481dbf22 /src
parentcommand: fix a race condition (diff)
downloadcimple-9f09e9676d2f95b6ab2c5b7a5c0c64888e4df6b3.tar.gz
cimple-9f09e9676d2f95b6ab2c5b7a5c0c64888e4df6b3.zip
log: prefix with thread ID
Diffstat (limited to 'src')
-rw-r--r--src/log.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/log.h b/src/log.h
index a0213ee..9b0c945 100644
--- a/src/log.h
+++ b/src/log.h
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
+#include <unistd.h>
static inline void log_print_timestamp(FILE *dest)
{
@@ -28,17 +29,23 @@ static inline void log_print_timestamp(FILE *dest)
return;
buf[0] = '\0';
- used += strftime(buf + used, sizeof(buf) - used, "[%F %T", &tm);
- used += snprintf(buf + used, sizeof(buf) - used, ".%03ld] ", tv.tv_usec / 1000);
+ used += strftime(buf + used, sizeof(buf) - used, "%F %T", &tm);
+ used += snprintf(buf + used, sizeof(buf) - used, ".%03ld | ", tv.tv_usec / 1000);
fprintf(dest, "%s", buf);
}
+static inline void log_print_thread_id(FILE *dest)
+{
+ fprintf(dest, "%d | ", gettid());
+}
+
#define CONCAT_INNER(a, b) a##b
#define CONCAT(a, b) CONCAT_INNER(a, b)
static inline void log_prefix(FILE *dest)
{
log_print_timestamp(dest);
+ log_print_thread_id(dest);
}
#define log_err_prefix() \