aboutsummaryrefslogtreecommitdiffstats
path: root/common/logging.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-11-15 13:46:14 +0000
committerWerner Koch <[email protected]>2017-11-15 13:51:09 +0000
commit8704304699bcbc1c10d0315ec7d25a1ae05c9905 (patch)
tree075e4e381d0c8c955e5d1958e6cc865e876b2047 /common/logging.c
parenti18n: Add an article to "agent" and lowercase "dirmngr" in one file. (diff)
downloadgnupg-8704304699bcbc1c10d0315ec7d25a1ae05c9905.tar.gz
gnupg-8704304699bcbc1c10d0315ec7d25a1ae05c9905.zip
common: Change log_clock to printf style.
* common/logging.c (log_clock): Use do_logv. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/logging.c')
-rw-r--r--common/logging.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/common/logging.c b/common/logging.c
index 82b21e25b..9f04a69de 100644
--- a/common/logging.c
+++ b/common/logging.c
@@ -1039,14 +1039,16 @@ log_printsexp () {}
is found in sexputils.c
*/
-/* Print a microsecond timestamp followed by STRING. */
+/* Print a microsecond timestamp followed by a FORMAT. */
void
-log_clock (const char *string)
+log_clock (const char *fmt, ...)
{
#if ENABLE_LOG_CLOCK
static unsigned long long initial;
struct timespec tv;
unsigned long long now;
+ char clockbuf[50];
+ va_list arg_ptr;
if (clock_gettime (CLOCK_REALTIME, &tv))
{
@@ -1059,10 +1061,20 @@ log_clock (const char *string)
if (!initial)
initial = now;
- log_debug ("[%6llu] %s", (now - initial)/1000, string);
+ snprintf (clockbuf, sizeof clockbuf, "[%6llu] ", (now - initial)/1000);
+ va_start (arg_ptr, fmt);
+ do_logv (GPGRT_LOG_DEBUG, 0, NULL, clockbuf, fmt, arg_ptr);
+ va_end (arg_ptr);
+
#else /*!ENABLE_LOG_CLOCK*/
+
/* You may need to link with -ltr to use the above code. */
- log_debug ("[not enabled by configure] %s", string);
+ va_list arg_ptr;
+
+ va_start (arg_ptr, fmt);
+ do_logv (GPGRT_LOG_DEBUG, 0, NULL, "[no clock] ", fmt, arg_ptr);
+ va_end (arg_ptr);
+
#endif /*!ENABLE_LOG_CLOCK*/
}