aboutsummaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog6
-rw-r--r--jnlib/logging.c18
-rw-r--r--jnlib/logging.h1
3 files changed, 23 insertions, 2 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index 651ed799f..05c8e98a5 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-25 Werner Koch <[email protected]>
+
+ * logging.c (get_tid_callback): New.
+ (do_logv): Use it.
+ (log_set_get_tid_callback): New.
+
2009-01-22 Werner Koch <[email protected]>
* t-support.c (gpg_err_code_from_errno)
diff --git a/jnlib/logging.c b/jnlib/logging.c
index df2ec4463..b06361980 100644
--- a/jnlib/logging.c
+++ b/jnlib/logging.c
@@ -1,6 +1,6 @@
/* logging.c - Useful logging functions
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
- * 2004, 2005, 2006 Free Software Foundation, Inc.
+ * 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
@@ -61,6 +61,7 @@ static char prefix_buffer[80];
static int with_time;
static int with_prefix;
static int with_pid;
+static unsigned long (*get_tid_callback)(void);
static int running_detached;
static int force_prefixes;
@@ -366,6 +367,13 @@ log_set_fd (int fd)
void
+log_set_get_tid_callback (unsigned long (*cb)(void))
+{
+ get_tid_callback = cb;
+}
+
+
+void
log_set_prefix (const char *text, unsigned int flags)
{
if (text)
@@ -460,7 +468,13 @@ do_logv (int level, const char *fmt, va_list arg_ptr)
if (with_prefix || force_prefixes)
fputs (prefix_buffer, logstream);
if (with_pid || force_prefixes)
- fprintf (logstream, "[%u]", (unsigned int)getpid ());
+ {
+ if (get_tid_callback)
+ fprintf (logstream, "[%u.%lx]",
+ (unsigned int)getpid (), get_tid_callback ());
+ else
+ fprintf (logstream, "[%u]", (unsigned int)getpid ());
+ }
if (!with_time || force_prefixes)
putc (':', logstream);
/* A leading backspace suppresses the extra space so that we can
diff --git a/jnlib/logging.h b/jnlib/logging.h
index 9da46e29e..0b96108a8 100644
--- a/jnlib/logging.h
+++ b/jnlib/logging.h
@@ -33,6 +33,7 @@ int log_get_errorcount (int clear);
void log_inc_errorcount (void);
void log_set_file( const char *name );
void log_set_fd (int fd);
+void log_set_get_tid_callback (unsigned long (*cb)(void));
void log_set_prefix (const char *text, unsigned int flags);
const char *log_get_prefix (unsigned int *flags);
int log_test_fd (int fd);