]> git.vomp.tv Git - vompclient.git/commitdiff
Implement Log trace-only mode
authorChris Tallon <chris@vomp.tv>
Fri, 3 Dec 2021 20:39:45 +0000 (20:39 +0000)
committerChris Tallon <chris@vomp.tv>
Fri, 3 Dec 2021 20:39:45 +0000 (20:39 +0000)
control.cc
log.cc
log.h

index 8427fced15eb345de39a37f2a1c35ebd271d3410..47f6e40c1bb9dcbacdb8d1446132dcd199061397 100644 (file)
@@ -408,6 +408,9 @@ void Control::run()
 
   inputMan->start();
 
+//  logger->debug(TAG, "Setting log trace only mode");
+//  logger->setTraceOnlyMode(true);
+
   messageLoopRun = true;
   messageLoop();
 
diff --git a/log.cc b/log.cc
index f5d51f743e1e4b2d6740cba8032924824eacb3e3..5687a79731192d010e770485d496e9e1b317ffbc 100644 (file)
--- a/log.cc
+++ b/log.cc
@@ -39,3 +39,8 @@ bool LogNT::init(const std::string& tfileName, bool tenabled)
 
   return true;
 }
+
+void LogNT::setTraceOnlyMode(bool t)
+{
+  traceOnlyMode = t;
+}
diff --git a/log.h b/log.h
index 10ac378f3b21b1aa2e7cf4b37f6063e22d541515..d477047ea2c9ef09c4e4865b0103b97784f061fa 100644 (file)
--- a/log.h
+++ b/log.h
@@ -48,6 +48,7 @@ class LogNT
     static LogNT* getInstance();
 
     bool init(const std::string& fileName, bool enabled);
+    void setTraceOnlyMode(bool);
 
     enum levels { TRACE, DEBUG, INFO, WARN, ERROR, CRIT };
 
@@ -66,6 +67,7 @@ class LogNT
     void ilog(const char* TAG, int level, T fmtString, Ts... args)
     {
       if (!enabled) return;
+      if (traceOnlyMode && (level != TRACE)) return;
 
       struct timeval tv;
       struct tm tms;
@@ -113,6 +115,7 @@ class LogNT
     std::ofstream logFile;
     std::mutex outLock;
     std::ostream* outstream;
+    bool traceOnlyMode{};
 };
 
 #endif