Initializing Multiple Logger Instances in an Application

5 views
Skip to first unread message

Timothy Peer

unread,
Nov 22, 2018, 5:39:59 PM11/22/18
to Qtilities
I have a need to produce two distinct loggers in a QT application.  The UI (QCoreApplication) and child threads (from QThreadPool). 

In Main: 

Created the the logging engine using the example code in the QTilitities page.
In each thread, I would like to add a custom engine initialized to a distinctly named file. How would one do this, I attempted to call Log->newFileEngine(engineName, logfileName); in a static class and implement the template LOG_INFO_E -> the logging facility does not seem to work.  

Is there an example of how this might be accomplished.


Case 1.  Use default Application Log.
Case 2. Foreach (thread of execution) write to LogFile.ThreadId

Many thanks!

Tim Peer

Jaco Naude

unread,
Nov 23, 2018, 1:57:05 AM11/23/18
to qtil...@googlegroups.com
Hi Tim

I haven't looked at the code in a while, but it should be doable and the whole logging system was designed to be thread safe.

Can you try (from the top of my head) to instead of using the LOG_INFO_E macros, connect a Qt::QueuedConnection signal from the appropriate thread to Qtilities::Logging::Logger::logMessage and specify the engine name for the thread you're logging from.

Cheers,
Jaco

--
--
To post to this group, send email to qtil...@googlegroups.com
To unsubscribe from this group, send email to
qtilities+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/qtilities?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "Qtilities" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtilities+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages