diff options
author | Werner Koch <[email protected]> | 2009-02-25 10:58:56 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-02-25 10:58:56 +0000 |
commit | 618afc4231521cfcf74c667c9edf6fdc47b8ffe1 (patch) | |
tree | 3468662f7fe8946795ed4ded198b53f21f458b79 /jnlib/logging.c | |
parent | Better debug output. (diff) | |
download | gnupg-618afc4231521cfcf74c667c9edf6fdc47b8ffe1.tar.gz gnupg-618afc4231521cfcf74c667c9edf6fdc47b8ffe1.zip |
Fixed a nasty bug in scdaemon which led to a card reset if the card was
inserted during scdaemon startup and a connection was made before the
ticker had a chance to run. Add some stuff for better debugging.
Diffstat (limited to 'jnlib/logging.c')
-rw-r--r-- | jnlib/logging.c | 18 |
1 files changed, 16 insertions, 2 deletions
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 |