New issue 113 by Van...@gmail.com: Logging from a library
http://code.google.com/p/google-glog/issues/detail?id=113
What steps will reproduce the problem?
1. Use glog in two libraries
2. Use two libraries that use glog in one project.
3. Call initialize code for both libraries.
What is the expected output? What do you see instead?
I expect that glog initializes quietly. Instead it shows me a message "You
called InitGoogleLogging() twice".
What version of the product are you using? On what operating system?
glog 0.3.2 on windows
Please provide any additional information below.
What do you propose to handle such a situation when a project consists of a
multiple libraries which are using glog? How to check if glog is already
initialized? Can glog be initiazed at compile time?
InitGoogleLogging should really be part of the application. Libraries are
free to use the LOG macros but they can't make assumptions about how the
user wants to initialize logging. I believe InitGoogleLogging is meant to
be called in the application 'main' (or similar)
Hm... what about dynamic loading?
I want to use logging in an NPAPI plugin (it is loaded dynamically by a
browser).
The problem is that I can't make an assumption that browser will call
InitGoogleLogging (I think it doesn't. I even can't be sure what it links
to glog). And if I develop another plugin, I want to be sure that I called
init only once.
Can I live without initialization?
Hm... What I can do is to link a plugin with glog statically and initialize
glog when a browser calls NP_Initialize. But then each plugin will have its
own glog copy. And if a browser rendering engine also links to glog, I
might have a problem.
> I believe InitGoogleLogging is meant to be called in the
> application 'main' (or similar)
So a library must export this symbol? Or an application should link to glog?