Right, so in order:
- You seem not to use the singleton pattern for singleton use cases.
- Your original question is not much related to Qt.
- This has little to nothing to do with the distinction of static library or not.
- You could make the plugin interface accept a logger mutator so that you could then set that with the instance from the application.
I would personally just use the singleton pattern properly, and the plugin could also query the very instance. Please take a look at the following Qt macro:
Q_GLOBAL_STATIC( Type, VariableName)
Creates a global and static object of type QGlobalStatic, of name VariableName and that behaves as a pointer to Type. The object created by Q_GLOBAL_STATIC initializes itself on the first use, which means that it will not increase the application or the library's load time. Additionally, the object is initialized in a thread-safe manner on all platforms.
You could easily build the singleton pattern on top of it, and actually this would be even thread-safe.
Here you can find another example not using Q_GLOBAL_STATIC
, but QObject
inheritance and facilitates the job with QCoreApplication
that we implemented in our project.
This version above is also-thread safe.