Commit c2cbc763 authored by 's avatar

Destruct global objects in ShutdownGoogleLogging

http://code.google.com/p/google-glog/issues/detail?id=69



git-svn-id: https://google-glog.googlecode.com/svn/trunk@96 eb4d4688-79bd-11dd-afb4-1d65580434c0
parent b1afbe7b
...@@ -311,8 +311,10 @@ class LogDestination { ...@@ -311,8 +311,10 @@ class LogDestination {
static const int kNetworkBytes = 1400; static const int kNetworkBytes = 1400;
static const string& hostname(); static const string& hostname();
private:
static void DeleteLogDestinations();
private:
LogDestination(LogSeverity severity, const char* base_filename); LogDestination(LogSeverity severity, const char* base_filename);
~LogDestination() { } ~LogDestination() { }
...@@ -607,6 +609,13 @@ inline LogDestination* LogDestination::log_destination(LogSeverity severity) { ...@@ -607,6 +609,13 @@ inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
return log_destinations_[severity]; return log_destinations_[severity];
} }
void LogDestination::DeleteLogDestinations() {
for (int severity = 0; severity < NUM_SEVERITIES; ++severity) {
delete log_destinations_[severity];
log_destinations_[severity] = NULL;
}
}
namespace { namespace {
LogFileObject::LogFileObject(LogSeverity severity, LogFileObject::LogFileObject(LogSeverity severity,
...@@ -1779,4 +1788,15 @@ LogMessageFatal::~LogMessageFatal() { ...@@ -1779,4 +1788,15 @@ LogMessageFatal::~LogMessageFatal() {
LogMessage::Fail(); LogMessage::Fail();
} }
void InitGoogleLogging(const char* argv0) {
glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
}
void ShutdownGoogleLogging() {
glog_internal_namespace_::ShutdownGoogleLoggingUtilities();
LogDestination::DeleteLogDestinations();
delete logging_directories_list;
logging_directories_list = NULL;
}
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
...@@ -311,9 +311,7 @@ void SetCrashReason(const CrashReason* r) { ...@@ -311,9 +311,7 @@ void SetCrashReason(const CrashReason* r) {
r); r);
} }
} // namespace glog_internal_namespace_ void InitGoogleLoggingUtilities(const char* argv0) {
void InitGoogleLogging(const char* argv0) {
CHECK(!IsGoogleLoggingInitialized()) CHECK(!IsGoogleLoggingInitialized())
<< "You called InitGoogleLogging() twice!"; << "You called InitGoogleLogging() twice!";
const char* slash = strrchr(argv0, '/'); const char* slash = strrchr(argv0, '/');
...@@ -328,7 +326,7 @@ void InitGoogleLogging(const char* argv0) { ...@@ -328,7 +326,7 @@ void InitGoogleLogging(const char* argv0) {
#endif #endif
} }
void ShutdownGoogleLogging() { void ShutdownGoogleLoggingUtilities() {
CHECK(IsGoogleLoggingInitialized()) CHECK(IsGoogleLoggingInitialized())
<< "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!";
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
...@@ -336,6 +334,8 @@ void ShutdownGoogleLogging() { ...@@ -336,6 +334,8 @@ void ShutdownGoogleLogging() {
#endif #endif
} }
} // namespace glog_internal_namespace_
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
// Make an implementation of stacktrace compiled. // Make an implementation of stacktrace compiled.
......
...@@ -214,6 +214,9 @@ struct CrashReason { ...@@ -214,6 +214,9 @@ struct CrashReason {
void SetCrashReason(const CrashReason* r); void SetCrashReason(const CrashReason* r);
void InitGoogleLoggingUtilities(const char* argv0);
void ShutdownGoogleLoggingUtilities();
} // namespace glog_internal_namespace_ } // namespace glog_internal_namespace_
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment