diff options
-rw-r--r-- | vespalog/src/vespa/log/log.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/vespalog/src/vespa/log/log.cpp b/vespalog/src/vespa/log/log.cpp index 635d982f529..2e19dda504c 100644 --- a/vespalog/src/vespa/log/log.cpp +++ b/vespalog/src/vespa/log/log.cpp @@ -39,6 +39,14 @@ char Logger::_hostname[1024] = { '\0'}; char Logger::_serviceName[1024] = {'\0' }; ControlFile *Logger::_controlFile = 0; +static inline unsigned long gettid(const void *tid) { + return reinterpret_cast<uint64_t>(tid) >> 3; +} + +static inline unsigned long gettid(unsigned long tid) { + return tid; +} + void Logger::ensureControlName() { @@ -265,7 +273,7 @@ void Logger::doLogCore(uint64_t timestamp, LogLevel level, // threads, only showing the least significant bits will hopefully // distinguish between all threads in your application. Alter later if // found to be too inaccurate. - int32_t tid = (fakePid ? -1 : pthread_self() % 0xffff); + int32_t tid = (fakePid ? -1 : gettid(pthread_self()) % 0xffff); if (_target->makeHumanReadable()) { time_t secs = static_cast<time_t>(timestamp / 1000000); |