aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Logging/ringlogger.c
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-13 18:00:29 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-13 18:00:32 +0530
commite199ed0d6c1ee89ff39c83193e945bfce5892777 (patch)
tree55a95cb47d2c6f2ef293da4ccb6fddbd0e12d543 /WireGuard/Shared/Logging/ringlogger.c
parentLogging: Use ringlogger for logging from the app (diff)
downloadwireguard-apple-e199ed0d6c1ee89ff39c83193e945bfce5892777.tar.xz
wireguard-apple-e199ed0d6c1ee89ff39c83193e945bfce5892777.zip
Logging: Tag the entries in the merged log
So we know which entry is from the app and which is from the network extension. Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/Shared/Logging/ringlogger.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/WireGuard/Shared/Logging/ringlogger.c b/WireGuard/Shared/Logging/ringlogger.c
index 11de0c3..5c6fae6 100644
--- a/WireGuard/Shared/Logging/ringlogger.c
+++ b/WireGuard/Shared/Logging/ringlogger.c
@@ -49,7 +49,7 @@ static bool first_before_second(const struct log_line *line1, const struct log_l
return false;
}
-int write_logs_to_file(const char *file_name, const struct log *log1, const struct log *log2)
+int write_logs_to_file(const char *file_name, const char *tag1, const struct log *log1, const char *tag2, const struct log *log2)
{
uint32_t i1, i2, len1 = log1->header.len, len2 = log2->header.len;
char buf[MAX_LOG_LINE_LENGTH];
@@ -68,19 +68,22 @@ int write_logs_to_file(const char *file_name, const struct log *log1, const stru
const struct log_line *line1 = &log1->lines[(log1->header.first + i1) % MAX_LINES];
const struct log_line *line2 = &log2->lines[(log2->header.first + i2) % MAX_LINES];
const struct log_line *line;
+ const char *tag;
if (i1 < len1 && (i2 >= len2 || first_before_second(line1, line2))) {
line = line1;
+ tag = (const char *) tag1;
++i1;
} else if (i2 < len2 && (i1 >= len1 || first_before_second(line2, line1))) {
line = line2;
+ tag = (const char *) tag2;
++i2;
} else {
break;
}
memcpy(buf, line->line, MAX_LOG_LINE_LENGTH);
buf[MAX_LOG_LINE_LENGTH - 1] = '\0';
- if (fprintf(file, "%lu.%06d: %s\n", line->tv.tv_sec, line->tv.tv_usec, buf) < 0) {
+ if (fprintf(file, "%lu.%06d: [%s] %s\n", line->tv.tv_sec, line->tv.tv_usec, tag, buf) < 0) {
int ret = -errno;
fclose(file);
return ret;