mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 10:09:36 +02:00
Logger: added %O to message format to display numeric thread id in logs.
This commit is contained in:
@@ -128,6 +128,9 @@ public:
|
|||||||
long getTid() const;
|
long getTid() const;
|
||||||
/// Returns the numeric thread identifier for the message.
|
/// Returns the numeric thread identifier for the message.
|
||||||
|
|
||||||
|
long getOsTid() const;
|
||||||
|
/// Returns the numeric OS thread identifier for the message.
|
||||||
|
|
||||||
void setPid(long pid);
|
void setPid(long pid);
|
||||||
/// Sets the process identifier for the message.
|
/// Sets the process identifier for the message.
|
||||||
|
|
||||||
@@ -196,6 +199,7 @@ private:
|
|||||||
Priority _prio;
|
Priority _prio;
|
||||||
Timestamp _time;
|
Timestamp _time;
|
||||||
int _tid;
|
int _tid;
|
||||||
|
int _ostid;
|
||||||
std::string _thread;
|
std::string _thread;
|
||||||
long _pid;
|
long _pid;
|
||||||
const char* _file;
|
const char* _file;
|
||||||
@@ -243,6 +247,12 @@ inline long Message::getTid() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline long Message::getOsTid() const
|
||||||
|
{
|
||||||
|
return _ostid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline long Message::getPid() const
|
inline long Message::getPid() const
|
||||||
{
|
{
|
||||||
return _pid;
|
return _pid;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class Foundation_API PatternFormatter: public Formatter
|
|||||||
/// * %P - message process identifier
|
/// * %P - message process identifier
|
||||||
/// * %T - message thread name
|
/// * %T - message thread name
|
||||||
/// * %I - message thread identifier (numeric)
|
/// * %I - message thread identifier (numeric)
|
||||||
|
/// * %O - message thread OS identifier (numeric)
|
||||||
/// * %N - node or host name
|
/// * %N - node or host name
|
||||||
/// * %U - message source file path (empty string if not set)
|
/// * %U - message source file path (empty string if not set)
|
||||||
/// * %u - message source line number (0 if not set)
|
/// * %u - message source line number (0 if not set)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace Poco {
|
|||||||
Message::Message():
|
Message::Message():
|
||||||
_prio(PRIO_FATAL),
|
_prio(PRIO_FATAL),
|
||||||
_tid(0),
|
_tid(0),
|
||||||
|
_ostid(0),
|
||||||
_pid(0),
|
_pid(0),
|
||||||
_file(0),
|
_file(0),
|
||||||
_line(0),
|
_line(0),
|
||||||
@@ -43,6 +44,7 @@ Message::Message(const std::string& source, const std::string& text, Priority pr
|
|||||||
_text(text),
|
_text(text),
|
||||||
_prio(prio),
|
_prio(prio),
|
||||||
_tid(0),
|
_tid(0),
|
||||||
|
_ostid(0),
|
||||||
_pid(0),
|
_pid(0),
|
||||||
_file(0),
|
_file(0),
|
||||||
_line(0),
|
_line(0),
|
||||||
@@ -57,6 +59,7 @@ Message::Message(const std::string& source, const std::string& text, Priority pr
|
|||||||
_text(text),
|
_text(text),
|
||||||
_prio(prio),
|
_prio(prio),
|
||||||
_tid(0),
|
_tid(0),
|
||||||
|
_ostid(0),
|
||||||
_pid(0),
|
_pid(0),
|
||||||
_file(file),
|
_file(file),
|
||||||
_line(line),
|
_line(line),
|
||||||
@@ -72,6 +75,7 @@ Message::Message(const Message& msg):
|
|||||||
_prio(msg._prio),
|
_prio(msg._prio),
|
||||||
_time(msg._time),
|
_time(msg._time),
|
||||||
_tid(msg._tid),
|
_tid(msg._tid),
|
||||||
|
_ostid(msg._ostid),
|
||||||
_thread(msg._thread),
|
_thread(msg._thread),
|
||||||
_pid(msg._pid),
|
_pid(msg._pid),
|
||||||
_file(msg._file),
|
_file(msg._file),
|
||||||
@@ -90,6 +94,7 @@ Message::Message(const Message& msg, const std::string& text):
|
|||||||
_prio(msg._prio),
|
_prio(msg._prio),
|
||||||
_time(msg._time),
|
_time(msg._time),
|
||||||
_tid(msg._tid),
|
_tid(msg._tid),
|
||||||
|
_ostid(msg._ostid),
|
||||||
_thread(msg._thread),
|
_thread(msg._thread),
|
||||||
_pid(msg._pid),
|
_pid(msg._pid),
|
||||||
_file(msg._file),
|
_file(msg._file),
|
||||||
@@ -113,6 +118,7 @@ void Message::init()
|
|||||||
#if !defined(POCO_VXWORKS)
|
#if !defined(POCO_VXWORKS)
|
||||||
_pid = Process::id();
|
_pid = Process::id();
|
||||||
#endif
|
#endif
|
||||||
|
_ostid = Thread::currentTid();
|
||||||
Thread* pThread = Thread::current();
|
Thread* pThread = Thread::current();
|
||||||
if (pThread)
|
if (pThread)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ void PatternFormatter::format(const Message& msg, std::string& text)
|
|||||||
case 'P': NumberFormatter::append(text, msg.getPid()); break;
|
case 'P': NumberFormatter::append(text, msg.getPid()); break;
|
||||||
case 'T': text.append(msg.getThread()); break;
|
case 'T': text.append(msg.getThread()); break;
|
||||||
case 'I': NumberFormatter::append(text, msg.getTid()); break;
|
case 'I': NumberFormatter::append(text, msg.getTid()); break;
|
||||||
|
case 'O': NumberFormatter::append(text, msg.getOsTid()); break;
|
||||||
case 'N': text.append(Environment::nodeName()); break;
|
case 'N': text.append(Environment::nodeName()); break;
|
||||||
case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
|
case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
|
||||||
case 'u': NumberFormatter::append(text, msg.getSourceLine()); break;
|
case 'u': NumberFormatter::append(text, msg.getSourceLine()); break;
|
||||||
|
|||||||
Reference in New Issue
Block a user