]> git.vomp.tv Git - vompclient.git/commitdiff
Implement Log shutdown
authorChris Tallon <chris@vomp.tv>
Mon, 15 Aug 2022 15:06:46 +0000 (15:06 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 15 Aug 2022 15:06:46 +0000 (15:06 +0000)
src/log.cc
src/log.h
src/main.cc

index 5687a79731192d010e770485d496e9e1b317ffbc..50a34d31875085d76f94b954a819ff87b48cf4cf 100644 (file)
@@ -24,12 +24,13 @@ bool LogNT::init(const std::string& tfileName, bool tenabled)
 {
   if (!tenabled) return true;
 
-  enabled = true;
-  fileName = tfileName; // Keep the filename for later?
+  if (enabled) return true;
 
+  fileName = tfileName; // Keep the filename for later?
   if (!fileName.compare("stdout"))
   {
     outstream = &std::cout;
+    enabled = true;
     return true;
   }
 
@@ -37,9 +38,21 @@ bool LogNT::init(const std::string& tfileName, bool tenabled)
   logFile.open(fileName, std::ios_base::out | std::ios_base::app);
   if (!logFile.is_open()) return false;
 
+  enabled = true;
   return true;
 }
 
+void LogNT::shutdown()
+{
+  if (!enabled) return;
+
+  traceOnlyMode = false;
+  info("LOG", "Shutting down... bye!\n\n");
+
+  enabled = false;
+  if (logFile.is_open()) logFile.close();
+}
+
 void LogNT::setTraceOnlyMode(bool t)
 {
   traceOnlyMode = t;
index d477047ea2c9ef09c4e4865b0103b97784f061fa..2a263db9b677ef15d6a2c1a76f6c474917d3a0f4 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -48,6 +48,7 @@ class LogNT
     static LogNT* getInstance();
 
     bool init(const std::string& fileName, bool enabled);
+    void shutdown();
     void setTraceOnlyMode(bool);
 
     enum levels { TRACE, DEBUG, INFO, WARN, ERROR, CRIT };
index 38f0014fb1b5170b2a5a4ca6cef1b2ddc0dc3daa..b3d9b260d5a1cf71e3e3801ef814c79abae7fb2d 100644 (file)
@@ -296,9 +296,7 @@ void threadSignalReceiverFunction()
 
   if (loggerNT)
   {
-    loggerNT->info(TAG, "Log module shutting down... bye!\n\n");
-#warning loggerNT has no shutdown
-    //loggerNT->shutdown();
+    loggerNT->shutdown();
     delete loggerNT;
   }