Destruct global objects in ShutdownGoogleLogging
author <shinichiro.hamaji@gmail.com> <>
Mon, 5 Sep 2011 08:00:01 +0000 (08:00 +0000)
committer <shinichiro.hamaji@gmail.com> <>
Mon, 5 Sep 2011 08:00:01 +0000 (08:00 +0000)
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

src/logging.cc
src/utilities.cc
src/utilities.h

index ec0ff5b..67e65f9 100644 (file)
@@ -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_
index 6df20a4..a1ee57e 100644 (file)
@@ -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.
index af9d0d4..42785dc 100644 (file)
@@ -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_