static dbus_bool_t verbose_initted = FALSE;
static dbus_bool_t verbose = TRUE;
-/** Whether to show the current thread in verbose messages */
-#define PTHREAD_IN_VERBOSE 0
-#if PTHREAD_IN_VERBOSE
-#include <pthread.h>
-#endif
-
#ifdef DBUS_USE_OUTPUT_DEBUG_STRING
static char module_name[1024];
#endif
/* Print out pid before the line */
if (need_pid)
{
-#if PTHREAD_IN_VERBOSE
- fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), pthread_self ());
-#else
- fprintf (stderr, "%lu: ", _dbus_pid_for_log ());
-#endif
+ _dbus_print_thread ();
}
#endif
#include <sys/time.h>
#include <pthread.h>
+#include <stdio.h>
#include <string.h>
#ifdef HAVE_ERRNO_H
{
pthread_mutex_unlock (&init_mutex);
}
+
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+/*
+ * If we can identify the current process and/or thread, print them to stderr followed by a colon.
+ */
+void
+_dbus_print_thread (void)
+{
+#ifdef __linux__
+ /* we know a pthread_t is numeric on Linux */
+ fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), (unsigned long) pthread_self ());
+#else
+ /* in principle pthread_t isn't required to be printable */
+ fprintf (stderr, "%lu: ", _dbus_pid_for_log ());
+#endif
+}
+#endif
_dbus_assert (global_init_done);
LeaveCriticalSection (&init_lock);
}
+
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+void
+_dbus_print_thread (void)
+{
+ fprintf (stderr, "%lu: 0x%04lx: ", _dbus_pid_for_log (), GetCurrentThreadId ());
+}
+#endif
/** @} end of sysdeps-win */
/* tests in dbus-sysdeps-util.c */
-
int _dbus_printf_string_upper_bound (const char *format,
va_list args);
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+DBUS_PRIVATE_EXPORT
+void _dbus_print_thread (void);
+#endif
/**
* Portable struct with stat() results