From dc0a833a4f7c2e77718468199fbec7b02aecbdb8 Mon Sep 17 00:00:00 2001 From: kouwenqi Date: Thu, 6 Jun 2024 17:50:15 +0800 Subject: [PATCH] adds a timestamp before each logged line --- ...-a-timestamp-before-each-logged-line.patch | 45 +++++++++++++++++++ libiscsi.spec | 6 ++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0024-backport-adds-a-timestamp-before-each-logged-line.patch diff --git a/0024-backport-adds-a-timestamp-before-each-logged-line.patch b/0024-backport-adds-a-timestamp-before-each-logged-line.patch new file mode 100644 index 0000000..58a1981 --- /dev/null +++ b/0024-backport-adds-a-timestamp-before-each-logged-line.patch @@ -0,0 +1,45 @@ +From 5fc2dcb88f2d8b52e83952f2dd3eedcdba383f71 Mon Sep 17 00:00:00 2001 +From: folkert van heusden +Date: Wed, 14 Feb 2024 00:44:26 +0100 +Subject: [PATCH] adds a timestamp before each logged line +Reference: https://github.com/sahlberg/libiscsi/pull/416/ + +--- + test-tool/iscsi-support.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c +index 169d2b0..07a2f52 100644 +--- a/test-tool/iscsi-support.c ++++ b/test-tool/iscsi-support.c +@@ -458,6 +458,8 @@ void logging(int level, const char *format, ...) + va_list ap; + static char message[1024]; + int ret; ++ struct timespec ts; ++ struct tm tm; + + if (loglevel < level) { + return; +@@ -468,6 +470,18 @@ void logging(int level, const char *format, ...) + return; + } + ++ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { ++ return; ++ } ++ ++ if (!localtime_r(&ts.tv_sec, &tm)) { ++ return; ++ } ++ ++ printf(" %04d-%02d-%02d %02d:%02d:%02d.%06d ", ++ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, (int)ts.tv_nsec / 1000); ++ ++ + va_start(ap, format); + ret = vsnprintf(message, 1024, format, ap); + va_end(ap); +-- +2.23.0 + diff --git a/libiscsi.spec b/libiscsi.spec index 0d58965..0e5ff69 100644 --- a/libiscsi.spec +++ b/libiscsi.spec @@ -1,6 +1,6 @@ Name: libiscsi Version: 1.19.0 -Release: 10 +Release: 11 Summary: Client-side library to implement the iSCSI protocol Recommends: %{name}-utils License: LGPLv2+ and GPLv2+ @@ -29,6 +29,7 @@ Patch20: 0020-Check-return-value-of-scsi_malloc-in-order-to.patch Patch21: 0021-Fix-segmentation-fault-problem.patch Patch22: 0022-init-fix-memory-leak-in-iscsi_create_context.patch Patch23: 0023-iscsi-command-Fix-leak-in-iscsi_send_data_out.patch +Patch24: 0024-backport-adds-a-timestamp-before-each-logged-line.patch Source: https://github.com/sahlberg/%{name}/archive/%{version}.tar.gz @@ -130,6 +131,9 @@ This package contains utilities of %{name} to connect to iSCSI targets %{_bindir}/iscsi-test-cu %changelog +* Thu Jun 6 2024 kouwenqi - 1.19.0-11 +- DESC:adds a timestamp before each logged line + * Wed Mar 22 2023 Wenchao Hao - 1.19.0-10 - DESC: backport patch to fix some memory leak issues -- Gitee