aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-07 16:05:41 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-07 16:05:41 +0000
commit2d5535b294c5e256313454e2657a84137eebc5f0 (patch)
treec625125d5530a11afe5058355b3de55d2b37c958
parent59f44a2a6d6af235455bc133dcdad6afa7ffb762 (diff)
downloadpaludis-2d5535b294c5e256313454e2657a84137eebc5f0.tar.gz
paludis-2d5535b294c5e256313454e2657a84137eebc5f0.tar.xz
Include the thread ID in log messages
-rw-r--r--paludis/util/log.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/paludis/util/log.cc b/paludis/util/log.cc
index 352a97f..dccb2fc 100644
--- a/paludis/util/log.cc
+++ b/paludis/util/log.cc
@@ -24,6 +24,16 @@
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/action_queue.hh>
+#include "config.h"
+
+#ifdef PALUDIS_ENABLE_THREADS
+# ifdef __linux__
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <unistd.h>
+# include <sys/syscall.h>
+# endif
+#endif
/** \file
* Implementation for Log.
@@ -156,7 +166,15 @@ void
Log::_message(const LogLevel l, const LogContext c, const std::string & s)
{
if (lc_context == c)
- _imp->action_queue.enqueue(tr1::bind(tr1::mem_fn(&Implementation<Log>::message), _imp.get(), l, c, Context::backtrace("\n ... "), s));
+ _imp->action_queue.enqueue(tr1::bind(tr1::mem_fn(&Implementation<Log>::message), _imp.get(), l, c,
+#ifdef PALUDIS_ENABLE_THREADS
+# ifdef __linux__
+ "In thread ID '" + stringify(syscall(SYS_gettid)) + "':\n ... " +
+# else
+# warning "Don't know how to get a thread ID on your platform"
+# endif
+#endif
+ Context::backtrace("\n ... "), s));
else
_imp->action_queue.enqueue(tr1::bind(tr1::mem_fn(&Implementation<Log>::message), _imp.get(), l, c, "", s));
}