Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP3:Update
sssd
0041-DEBUG-changed-timestamp-output-format.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0041-DEBUG-changed-timestamp-output-format.patch of Package sssd
From 306d6f4fd35b7cafd727b56699ed8b56b40e6560 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov <atikhono@redhat.com> Date: Mon, 4 May 2020 16:54:13 +0200 Subject: [PATCH 2/5] DEBUG: changed timestamp output format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed timestamp format from (example) "(Tue Apr 21 14:35:30 2020)" to "(2020-04-21 14:35:30)" to have tidier and "sorting friendly" logs. Reviewed-by: Pawel Polawski <ppolawsk@redhat.com> (cherry picked from commit 7b25375155e7b7f640d30dcfdf5b55482a6102a7) Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> --- src/tests/debug-tests.c | 32 ++++++++++++++++---------------- src/util/debug.c | 24 +++++++----------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c index 1446ec047..95b0a8f00 100644 --- a/src/tests/debug-tests.c +++ b/src/tests/debug-tests.c @@ -190,29 +190,29 @@ int test_helper_debug_check_message(int level) msg[fsize] = '\0'; if (debug_timestamps == 1) { - char time_day[4] = {'\0', '\0', '\0', '\0'}; - char time_month[4] = {'\0', '\0', '\0', '\0'}; - int time_day_num = 0; int time_hour = 0; int time_min = 0; int time_sec = 0; int time_usec = 0; + int time_day = 0; + int time_month = 0; int time_year = 0; int scan_return = 0; if (debug_microseconds == 0) { - scan_return = sscanf(msg, "(%s %s %d %d:%d:%d %d)", time_day, time_month, - &time_day_num, &time_hour, &time_min, &time_sec, &time_year); + scan_return = sscanf(msg, "(%d-%d-%d %d:%d:%d)", &time_year, + &time_month, &time_day, &time_hour, + &time_min, &time_sec); - if (scan_return != 7) { + if (scan_return != 6) { ret = DEBUG_TEST_NOK_TS; goto done; } compare_to = talloc_asprintf(ctx, - "(%s %s %2d %.2d:%.2d:%.2d %.4d) " + "(%d-%02d-%02d %2d:%02d:%02d): " "[%s] [%s] (%#.4x): %s\n", - time_day, time_month, time_day_num, - time_hour, time_min, time_sec, time_year, + time_year, time_month, time_day, + time_hour, time_min, time_sec, debug_prg_name, function, level, body); if (compare_to == NULL) { _errno = ENOMEM; @@ -220,20 +220,20 @@ int test_helper_debug_check_message(int level) goto done; } } else { - scan_return = sscanf(msg, "(%s %s %d %d:%d:%d:%d %d)", time_day, time_month, - &time_day_num, &time_hour, &time_min, &time_sec, - &time_usec, &time_year); + scan_return = sscanf(msg, "(%d-%d-%d %d:%d:%d:%d)", &time_year, + &time_month, &time_day, &time_hour, + &time_min, &time_sec, &time_usec); - if (scan_return != 8) { + if (scan_return != 7) { ret = DEBUG_TEST_NOK_TS; goto done; } compare_to = talloc_asprintf(ctx, - "(%s %s %2d %.2d:%.2d:%.2d:%.6d %.4d) " + "(%d-%02d-%02d %2d:%02d:%02d:%.6d): " "[%s] [%s] (%#.4x): %s\n", - time_day, time_month, time_day_num, + time_year, time_month, time_day, time_hour, time_min, time_sec, time_usec, - time_year, debug_prg_name, function, level, body); + debug_prg_name, function, level, body); if (compare_to == NULL) { _errno = ENOMEM; ret = DEBUG_TEST_ERROR; diff --git a/src/util/debug.c b/src/util/debug.c index 001445e5a..0e47129e5 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -270,8 +270,6 @@ void sss_vdebug_fn(const char *file, { struct timeval tv; struct tm *tm; - char datetime[20]; - int year; #ifdef WITH_JOURNALD errno_t ret; @@ -300,25 +298,17 @@ void sss_vdebug_fn(const char *file, if (debug_timestamps) { gettimeofday(&tv, NULL); tm = localtime(&tv.tv_sec); - year = tm->tm_year + 1900; - /* get date time without year */ - memcpy(datetime, ctime(&tv.tv_sec), 19); - datetime[19] = '\0'; + debug_printf("(%d-%02d-%02d %2d:%02d:%02d", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); if (debug_microseconds) { - debug_printf("(%s:%.6ld %d) [%s] [%s] (%#.4x): ", - datetime, tv.tv_usec, - year, debug_prg_name, - function, level); - } else { - debug_printf("(%s %d) [%s] [%s] (%#.4x): ", - datetime, year, - debug_prg_name, function, level); + debug_printf(":%.6ld", tv.tv_usec); } - } else { - debug_printf("[%s] [%s] (%#.4x): ", - debug_prg_name, function, level); + debug_printf("): "); } + debug_printf("[%s] [%s] (%#.4x): ", debug_prg_name, function, level); + debug_vprintf(format, ap); if (flags & APPEND_LINE_FEED) { debug_printf("\n"); -- 2.32.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor