Issue 113 in google-glog: Logging from a library

357 views
Skip to first unread message

codesite...@google.com

unread,
Jan 23, 2012, 5:37:41 AM1/23/12
to googl...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

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?


codesite...@google.com

unread,
Mar 15, 2012, 5:05:42 PM3/15/12
to googl...@googlegroups.com

Comment #1 on issue 113 by diwakerg...@gmail.com: Logging from a library
http://code.google.com/p/google-glog/issues/detail?id=113

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)

codesite...@google.com

unread,
Mar 15, 2012, 5:29:02 PM3/15/12
to googl...@googlegroups.com

Comment #2 on issue 113 by Van...@gmail.com: Logging from a library
http://code.google.com/p/google-glog/issues/detail?id=113

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?

codesite...@google.com

unread,
Jul 9, 2012, 7:57:49 AM7/9/12
to googl...@googlegroups.com

Comment #3 on issue 113 by Van...@gmail.com: Logging from a library
http://code.google.com/p/google-glog/issues/detail?id=113

Even if I link glog statically, I'll still have one InitGoogleLogging
symbol :(
So, won't glog crash if I call init multiple times?

codesite...@google.com

unread,
Jul 9, 2012, 11:02:37 AM7/9/12
to googl...@googlegroups.com

Comment #4 on issue 113 by Van...@gmail.com: Logging from a library
http://code.google.com/p/google-glog/issues/detail?id=113

Could glog expose a function "IsGoogleLoggingInitialized()"?

Reply all
Reply to author
Forward
0 new messages