Skip to content

Logger message: added %O for numeric OS thread id#843

Closed
matejk wants to merge 3 commits intopocoproject:developfrom
matejk:develop-logger-os-tid
Closed

Logger message: added %O for numeric OS thread id#843
matejk wants to merge 3 commits intopocoproject:developfrom
matejk:develop-logger-os-tid

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented May 29, 2015

Log message: added %O option to insert numeric platform specific thread id. Useful when using Poco logger in non-Poco threads (like std::thread) to be able to distinguish between threads in log messages.

Thread ID implemented for Linux and OSX.

…ad id. Useful when using Poco logger in non-Poco threads (like std::thread) to be able to distinguish between threads in log messages.
@matejk
Copy link
Copy Markdown
Contributor Author

matejk commented May 30, 2015

The purpose of system-specific numeric thread id is to be able to use it logger to display thread ID when using non-Poco threads, like std::thread.

If currentTid() is always numeric that it can be used for this purpose, yes.

I'll update the code.

@matejk
Copy link
Copy Markdown
Contributor Author

matejk commented May 30, 2015

Moved implementation from Message to Thread*.

However I noticed that only some posix platforms have different pthread and OS thread IDs and it is more convenient for tracing purposes to use OS tids.

One of the options would also be to change Posix implementation of Thread::getTid() to return OS numeric thread id instead of pthread_self (type pthread_t).

@aleks-f
Copy link
Copy Markdown
Member

aleks-f commented May 30, 2015

The downside, as I mentioned, is a bit too many thread IDs for my taste; so, I'd modify Thread::currentTid() to return kernel ID, which decouples it from both Poco and the platform thread interface. Threading now in practice boils down to pthread and win32 threads but who knows what future may hold. But, if we accept the proposal in this last pull and have three thread ID calls, I'm fine with that too.

@obiltschnig
Copy link
Copy Markdown
Member

Two thread IDs (one from Poco::Thread, one from system) should be enough. Three is definitely too many.

@matejk
Copy link
Copy Markdown
Contributor Author

matejk commented May 30, 2015

Removed functions to get the third thread ID and rather changed implementation of tid() and currentTid() for posix implementation to return kernel threads for Linux and OS X.

If this implementation is acceptable, I'd clean create new pull request with clean code changes.

@matejk
Copy link
Copy Markdown
Contributor Author

matejk commented Jun 1, 2015

Created new pull request #846 with cleaned up code changes.

@aleks-f aleks-f closed this Jun 1, 2015
@matejk matejk deleted the develop-logger-os-tid branch June 1, 2015 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants