diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-03-23 09:23:25 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-03-23 09:33:58 +0900 |
commit | 976094c6b99cecbe9f21399af30fb167fb731610 (patch) | |
tree | 673a05025898d3d3533bb4d356eb52b8f5c803cf | |
parent | b6cbaa5e25ff276d22d3a3f283d97b2883ecaf88 (diff) | |
download | tdelibs-976094c6b99cecbe9f21399af30fb167fb731610.tar.gz tdelibs-976094c6b99cecbe9f21399af30fb167fb731610.zip |
Add pid value to debug messages.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 0970152d072a61355c77572abbf35b701aa800d3)
-rw-r--r-- | tdecore/kdebug.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tdecore/kdebug.cpp b/tdecore/kdebug.cpp index 9cc32225c..afd925190 100644 --- a/tdecore/kdebug.cpp +++ b/tdecore/kdebug.cpp @@ -295,18 +295,20 @@ static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char return; } - const int BUFSIZE = 4096; - char buf[BUFSIZE]; - if ( !kDebug_data->aAreaName.isEmpty() ) { - strlcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] [").ascii(), BUFSIZE ); - strlcat( buf, kDebug_data->aAreaName.data(), BUFSIZE ); - strlcat( buf, "] ", BUFSIZE ); - strlcat( buf, data, BUFSIZE ); - } - else { - strlcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii(), BUFSIZE ); - strlcat( buf, data, BUFSIZE ); + const int BUF_SIZE = 4096; + const int BUF_PID_SIZE = 20; + char buf[BUF_SIZE]; + char buf_pid[BUF_PID_SIZE]; + strlcpy(buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii(), BUF_SIZE); + if (!kDebug_data->aAreaName.isEmpty()) + { + strlcat( buf, "[", BUF_SIZE ); + strlcat( buf, kDebug_data->aAreaName.data(), BUF_SIZE ); + strlcat( buf, "] ", BUF_SIZE ); } + snprintf(buf_pid, BUF_PID_SIZE, "[%d] ", getpid()); + strlcat(buf, buf_pid, BUF_SIZE); + strlcat(buf, data, BUF_SIZE); // Output switch( nOutput ) |