diff --git a/CHANGELOG.md b/CHANGELOG.md index a46d6ef3e..0a3e5aece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ### Changed - api: add support of date like ISO 8601 but with spaces and lower `t` and `z` in function util_parse_time +- logger: change default time format to "%@%F %T.%fZ" (UTC) - logger: use function util_parse_time to parse date/time in log files - build: require Curl ≥ 7.68.0 ([#2268](https://github.com/weechat/weechat/issues/2268)) - build: require GnuTLS ≥ 3.6.3 ([#2268](https://github.com/weechat/weechat/issues/2268)) diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c index 7140257ce..221cbd5a3 100644 --- a/src/plugins/logger/logger-config.c +++ b/src/plugins/logger/logger-config.c @@ -718,7 +718,7 @@ logger_config_init (void) N_("timestamp used in log files (see man strftime for date/time " "specifiers, extra specifiers are supported, see function " "util_strftimeval in Plugin API reference)"), - NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, + NULL, 0, 0, "%@%F %T.%fZ", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } diff --git a/tests/unit/plugins/logger/test-logger-backlog.cpp b/tests/unit/plugins/logger/test-logger-backlog.cpp index 410fef124..06288599c 100644 --- a/tests/unit/plugins/logger/test-logger-backlog.cpp +++ b/tests/unit/plugins/logger/test-logger-backlog.cpp @@ -103,7 +103,7 @@ TEST(LoggerBacklog, DisplayLine) /* valid line */ snprintf (str_line, sizeof (str_line), - "2022-02-19 16:32:20\tnick\tthe message"); + "2022-02-19 16:32:20.123456Z\tnick\tthe message"); logger_backlog_display_line (gui_buffers, str_line); ptr_data = gui_buffers->own_lines->last_line->data; LONGS_EQUAL(1645288340, ptr_data->date); @@ -127,7 +127,7 @@ TEST(LoggerBacklog, DisplayLine) /* valid line with Tab in message */ snprintf (str_line, sizeof (str_line), - "2022-02-19 16:32:21\tnick\tthe message\twith tab"); + "2022-02-19 16:32:21.123456Z\tnick\tthe message\twith tab"); logger_backlog_display_line (gui_buffers, str_line); ptr_data = gui_buffers->own_lines->last_line->data; LONGS_EQUAL(1645288341, ptr_data->date); @@ -193,19 +193,19 @@ TEST(LoggerBacklog, GroupMessages) { struct t_arraylist *lines, *messages; const char *test_lines_1[] = { - "2023-06-04 21:15:34\t\tMessage 1", - "2023-06-04 21:15:40\t\tMessage 2", + "2023-06-04 21:15:34.123456Z\t\tMessage 1", + "2023-06-04 21:15:40.123456Z\t\tMessage 2", NULL, }; const char *test_lines_2[] = { "end of line", - "2023-06-04 21:15:34\t\tFirst line", + "2023-06-04 21:15:34.123456Z\t\tFirst line", "of multiline message", "", "end of message", - "2023-06-04 21:15:37\t\tTwo lines with empty line", + "2023-06-04 21:15:37.123456Z\t\tTwo lines with empty line", "", - "2023-06-04 21:15:40\t\tMessage on one line", + "2023-06-04 21:15:40.123456Z\t\tMessage on one line", NULL, }; int i; @@ -224,9 +224,9 @@ TEST(LoggerBacklog, GroupMessages) messages = logger_backlog_group_messages (lines); CHECK(messages); LONGS_EQUAL(2, arraylist_size (messages)); - STRCMP_EQUAL("2023-06-04 21:15:34\t\tMessage 1", + STRCMP_EQUAL("2023-06-04 21:15:34.123456Z\t\tMessage 1", (const char *)arraylist_get (messages, 0)); - STRCMP_EQUAL("2023-06-04 21:15:40\t\tMessage 2", + STRCMP_EQUAL("2023-06-04 21:15:40.123456Z\t\tMessage 2", (const char *)arraylist_get (messages, 1)); arraylist_free (messages); @@ -242,14 +242,14 @@ TEST(LoggerBacklog, GroupMessages) LONGS_EQUAL(4, arraylist_size (messages)); STRCMP_EQUAL("end of line", (const char *)arraylist_get (messages, 0)); - STRCMP_EQUAL("2023-06-04 21:15:34\t\tFirst line\n" + STRCMP_EQUAL("2023-06-04 21:15:34.123456Z\t\tFirst line\n" "of multiline message\n" "\n" "end of message", (const char *)arraylist_get (messages, 1)); - STRCMP_EQUAL("2023-06-04 21:15:37\t\tTwo lines with empty line\n", + STRCMP_EQUAL("2023-06-04 21:15:37.123456Z\t\tTwo lines with empty line\n", (const char *)arraylist_get (messages, 2)); - STRCMP_EQUAL("2023-06-04 21:15:40\t\tMessage on one line", + STRCMP_EQUAL("2023-06-04 21:15:40.123456Z\t\tMessage on one line", (const char *)arraylist_get (messages, 3)); arraylist_free (messages);