Add ShutdownGoogleLogging to close syslog.
author <shinichiro.hamaji@gmail.com> <>
Tue, 15 Jun 2010 06:28:38 +0000 (06:28 +0000)
committer <shinichiro.hamaji@gmail.com> <>
Tue, 15 Jun 2010 06:28:38 +0000 (06:28 +0000)
This patch was contributed by DGunchev (thanks!)

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

git-svn-id: https://google-glog.googlecode.com/svn/trunk@88 eb4d4688-79bd-11dd-afb4-1d65580434c0

src/glog/logging.h.in
src/logging_unittest.cc
src/utilities.cc
src/windows/glog/logging.h

index 16ba6942c75945ca08a488df8bc7e36802d9d012..ff23f2e90a36941ea7f0ddf1ab05a2309f117629 100644 (file)
@@ -482,6 +482,9 @@ DECLARE_bool(stop_logging_if_full_disk);
 // specified by argv0 in log outputs.
 GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
 
+// Shutdown google's logging library.
+GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
+
 // Install a function which will be called after LOG(FATAL).
 GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
 
index fb058e74844eed719efe672c218cc6fae51d9483..5fc34d4a4e2f8aa7d48c413bc82f5dcb34a83637 100644 (file)
@@ -227,6 +227,8 @@ int main(int argc, char **argv) {
   TestErrno();
   TestTruncate();
 
+  ShutdownGoogleLogging();
+
   fprintf(stdout, "PASS\n");
   return 0;
 }
index bd4e4adc1bc4b63493eeab68b334117fc931ef83..e97d4f237ec20aa22bf2611cfdd32be74be324c4 100644 (file)
@@ -44,6 +44,9 @@
 #elif defined(HAVE_SYS_SYSCALL_H)
 #include <sys/syscall.h>                 // for syscall()
 #endif
+#ifdef HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
 
 #include "base/googleinit.h"
 
@@ -316,6 +319,14 @@ void InitGoogleLogging(const char* argv0) {
 #endif
 }
 
+void ShutdownGoogleLogging() {
+  CHECK(IsGoogleLoggingInitialized())
+      << "You called ShutdownGoogleLogging() without InitGoogleLogging() first!";
+#ifdef HAVE_SYSLOG_H
+  closelog();
+#endif
+}
+
 _END_GOOGLE_NAMESPACE_
 
 // Make an implementation of stacktrace compiled.
index a63246d6a3309944caa095e9679cddfcfd3c04e4..7a6df74f4941c8220a8e3da19489c3efd97073a0 100755 (executable)
@@ -486,6 +486,9 @@ namespace google {
 // specified by argv0 in log outputs.
 GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
 
+// Shutdown google's logging library.
+GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
+
 // Install a function which will be called after LOG(FATAL).
 GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());