Skip to content

Commit

Permalink
Merge pull request #16655 from peak3d/logpid
Browse files Browse the repository at this point in the history
[Log] Use Thread ID instead NativeHandle for logging
  • Loading branch information
peak3d committed Sep 23, 2019
2 parents 57577ae + 3bd700c commit 2284918
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions xbmc/threads/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CThread
static int GetMaxPriority(void);
static int GetNormalPriority(void);
static std::uintptr_t GetCurrentThreadNativeHandle();
static uint64_t GetCurrentThreadNativeId();

// Get and set the thread's priority
int GetPriority(void);
Expand Down
5 changes: 5 additions & 0 deletions xbmc/threads/platform/pthreads/ThreadImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ std::uintptr_t CThread::GetCurrentThreadNativeHandle()
#endif
}

uint64_t CThread::GetCurrentThreadNativeId()
{
return static_cast<uint64_t>(GetCurrentThreadPid_());
}

int CThread::GetMinPriority(void)
{
// one level lower than application
Expand Down
5 changes: 5 additions & 0 deletions xbmc/threads/platform/win/ThreadImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ std::uintptr_t CThread::GetCurrentThreadNativeHandle()
return reinterpret_cast<std::uintptr_t>(::GetCurrentThread());
}

uint64_t CThread::GetCurrentThreadNativeId()
{
return static_cast<uint64_t>(::GetCurrentThreadId());
}

int CThread::GetMinPriority(void)
{
return(THREAD_PRIORITY_IDLE);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/utils/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ bool CLog::WriteLogString(int logLevel, const std::string& logString)
minute,
second,
static_cast<int>(millisecond),
static_cast<uint64_t>(CThread::GetCurrentThreadNativeHandle()),
static_cast<uint64_t>(CThread::GetCurrentThreadNativeId()),
levelNames[logLevel]) + strData;

return g_logState.m_platform.WriteStringToLog(strData);
Expand Down

0 comments on commit 2284918

Please sign in to comment.