Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose IsGoogleLoggingInitialized() in public API. #651

Merged
merged 1 commit into from
May 14, 2021

Conversation

xkszltl
Copy link
Contributor

@xkszltl xkszltl commented May 13, 2021

Usually library does not have control of the process lifespan.
Without this function, it is impossible to init/shutdown reliably.
It has been one of the major pain points for years when using glog in libraries.

AFAIK 3 workarounds have been used previously:

  1. Init without checking. This causes compatiblity issues with other libs using glog.
  2. Also provide a init function in library's API. This makes API complicated and stateful, especially for libs that does not mean to stay for the entire life of process.
  3. Steal the utility function in internal namespace. Does not work with msvc (due to missing dllexport) or gcc -fvisibility=hidden.

None of them are perfect, except for the last hack that usually works well on Linux.
0.5.0 changes default visibility to hidden and it does not work anymore.

Resolve #125

@google-cla google-cla bot added the cla: yes label May 13, 2021
@xkszltl
Copy link
Contributor Author

xkszltl commented May 13, 2021

@sergiud

Copy link
Collaborator

@sergiud sergiud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple test checking the result of IsGoogleLoggingInitialized before and after init, and also after a shutdown should be added as well.

src/logging.cc Outdated Show resolved Hide resolved
@sergiud sergiud self-assigned this May 13, 2021
@sergiud sergiud added this to the next milestone May 13, 2021
@xkszltl
Copy link
Contributor Author

xkszltl commented May 13, 2021

Tests added.

src/utilities.cc Outdated Show resolved Hide resolved
src/utilities.h Outdated Show resolved Hide resolved
Usually library does not have control of the process lifespan.
Without this function, it is impossible to init/shutdown reliably.
It has been one of the major pain points for years when using glog in libraries.

AFAIK 3 workarounds have been used previously:
1. Init without checking. This causes compatiblity issues with other libs using glog.
2. Also provide a init function in library's API. This makes API complicated and stateful, especially for libs that does not mean to stay for the entire life of process.
3. Steal the utility function in internal namespace. Does not work with msvc (due to missing dllexport) or `gcc -fvisibility=hidden`.

None of them are perfect, except for the last hack that usually works well on Linux.
0.5.0 changes default visibility to hidden and it does not work anymore.

Resolve google#125
@xkszltl
Copy link
Contributor Author

xkszltl commented May 14, 2021

Added decl in logging.h and def in utilities.cc as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow glog to be queried as to whether or not InitGoogleLogging has been called.
2 participants