diff options
author | <shinichiro.hamaji@gmail.com> | 2011-09-05 08:00:01 +0000 |
---|---|---|
committer | <shinichiro.hamaji@gmail.com> | 2011-09-05 08:00:01 +0000 |
commit | c2cbc763edd6cb32ef040eb22ff10bf8b8e8c797 (patch) | |
tree | 2618625883a555afb9d0c13f63b58c8355d0e6b5 | |
parent | b1afbe7b3caab5cc4a3ffa6d9250adb282508e62 (diff) | |
download | glog-c2cbc763edd6cb32ef040eb22ff10bf8b8e8c797.tar.gz glog-c2cbc763edd6cb32ef040eb22ff10bf8b8e8c797.tar.bz2 glog-c2cbc763edd6cb32ef040eb22ff10bf8b8e8c797.zip |
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
-rw-r--r-- | src/logging.cc | 22 | ||||
-rw-r--r-- | src/utilities.cc | 8 | ||||
-rw-r--r-- | src/utilities.h | 3 |
3 files changed, 28 insertions, 5 deletions
diff --git a/src/logging.cc b/src/logging.cc index ec0ff5b..67e65f9 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -311,8 +311,10 @@ class LogDestination { static const int kNetworkBytes = 1400; static const string& hostname(); - private: + static void DeleteLogDestinations(); + + private: LogDestination(LogSeverity severity, const char* base_filename); ~LogDestination() { } @@ -607,6 +609,13 @@ inline LogDestination* LogDestination::log_destination(LogSeverity 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 { LogFileObject::LogFileObject(LogSeverity severity, @@ -1779,4 +1788,15 @@ LogMessageFatal::~LogMessageFatal() { 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_ diff --git a/src/utilities.cc b/src/utilities.cc index 6df20a4..a1ee57e 100644 --- a/src/utilities.cc +++ b/src/utilities.cc @@ -311,9 +311,7 @@ void SetCrashReason(const CrashReason* r) { r); } -} // namespace glog_internal_namespace_ - -void InitGoogleLogging(const char* argv0) { +void InitGoogleLoggingUtilities(const char* argv0) { CHECK(!IsGoogleLoggingInitialized()) << "You called InitGoogleLogging() twice!"; const char* slash = strrchr(argv0, '/'); @@ -328,7 +326,7 @@ void InitGoogleLogging(const char* argv0) { #endif } -void ShutdownGoogleLogging() { +void ShutdownGoogleLoggingUtilities() { CHECK(IsGoogleLoggingInitialized()) << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; #ifdef HAVE_SYSLOG_H @@ -336,6 +334,8 @@ void ShutdownGoogleLogging() { #endif } +} // namespace glog_internal_namespace_ + _END_GOOGLE_NAMESPACE_ // Make an implementation of stacktrace compiled. diff --git a/src/utilities.h b/src/utilities.h index af9d0d4..42785dc 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -214,6 +214,9 @@ struct CrashReason { void SetCrashReason(const CrashReason* r); +void InitGoogleLoggingUtilities(const char* argv0); +void ShutdownGoogleLoggingUtilities(); + } // namespace glog_internal_namespace_ _END_GOOGLE_NAMESPACE_ |