[checkmk-commits] Trace output to log file is enabled

Sergey Kipnis sk at mathias-kettner.de
Thu Apr 18 10:20:22 CEST 2019


Module: check_mk
Branch: master
Commit: f155dc6d049dcc243c0bcbe449fd59f15473ad26
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f155dc6d049dcc243c0bcbe449fd59f15473ad26

Author: Sergey Kipnis <sk at mathias-kettner.de>
Date:   Thu Apr 18 10:11:53 2019 +0200

Trace output to log file is enabled

Change-Id: Ic9f37f5b7bb4bb567a812cedd2ec6aa82a1ebc99

---

 agents/wnx/src/engine/cfg.h              |  5 ++++-
 agents/wnx/src/engine/cma_core.cpp       | 10 ++++++----
 agents/wnx/src/engine/logger.cpp         |  5 ++++-
 agents/wnx/src/engine/providers/mrpe.cpp | 20 +++++++++-----------
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/agents/wnx/src/engine/cfg.h b/agents/wnx/src/engine/cfg.h
index 18f41bd..dd2001b 100644
--- a/agents/wnx/src/engine/cfg.h
+++ b/agents/wnx/src/engine/cfg.h
@@ -1017,7 +1017,7 @@ private:
     bool async_start_;
     int max_wait_;
 
-};  // namespace cma::cfg
+};
 
 void LoadExeUnitsFromYaml(std::vector<Plugins::ExeUnit>& ExeUnit,
                           const std::vector<YAML::Node> Yaml);
@@ -1031,6 +1031,9 @@ extern Plugins plugins;
 extern Plugins localGroup;
 }  // namespace groups
 
+inline bool LogPluginOutput() { return false; }
+inline bool LogMrpeOutput() { return false; }
+
 }  // namespace cma::cfg
 
 #include "cfg_details.h"
diff --git a/agents/wnx/src/engine/cma_core.cpp b/agents/wnx/src/engine/cma_core.cpp
index f86c698..b38ec7b 100644
--- a/agents/wnx/src/engine/cma_core.cpp
+++ b/agents/wnx/src/engine/cma_core.cpp
@@ -237,8 +237,9 @@ std::vector<char> PluginEntry::getResultsSync(const std::wstring& Id,
             auto data = wtools::ConditionallyConvertFromUTF16(Data);
             cma::tools::AddVector(accu, data);
             storeData(Pid, accu);
-            XLOG::t("Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
-                    wtools::ConvertToUTF8(CmdLine), Pid, Code, data.data());
+            if (cma::cfg::LogPluginOutput())
+                XLOG::t("Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
+                        wtools::ConvertToUTF8(CmdLine), Pid, Code, data.data());
         });
 
     } else {
@@ -311,8 +312,9 @@ void PluginEntry::threadCore(const std::wstring& Id) {
                 std::lock_guard l(data_lock_);
                 storeData(Pid, accu);
             }
-            XLOG::t("Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
-                    wtools::ConvertToUTF8(CmdLine), Pid, Code, data.data());
+            if (cma::cfg::LogPluginOutput())
+                XLOG::t("Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
+                        wtools::ConvertToUTF8(CmdLine), Pid, Code, data.data());
         });
     } else {
         // timeout or break signaled
diff --git a/agents/wnx/src/engine/logger.cpp b/agents/wnx/src/engine/logger.cpp
index 53f2846..77fba8c 100644
--- a/agents/wnx/src/engine/logger.cpp
+++ b/agents/wnx/src/engine/logger.cpp
@@ -26,7 +26,7 @@ public:
     GlobalLogSettings() {
         enable(LogType::log);
         enable(LogType::debug);
-        // enable(LogType::kTrace);
+        enable(LogType::trace);
         enable(LogType::stdio);
     }
 
@@ -247,15 +247,18 @@ void ChangeDebugLogLevel(int Level) {
         case LogLevel::kLogAll:
             setup::EnableTraceLog(true);
             setup::EnableDebugLog(true);
+            XLOG::t("Enabled All");
             break;
         case LogLevel::kLogDebug:
             setup::EnableTraceLog(false);
             setup::EnableDebugLog(true);
+            XLOG::d.t("Enabled Debug");
             break;
         case LogLevel::kLogBase:
         default:
             setup::EnableTraceLog(false);
             setup::EnableDebugLog(false);
+            XLOG::l.t("Enabled Base");
             break;
     }
 }
diff --git a/agents/wnx/src/engine/providers/mrpe.cpp b/agents/wnx/src/engine/providers/mrpe.cpp
index 2e2ee61..380b3e9 100644
--- a/agents/wnx/src/engine/providers/mrpe.cpp
+++ b/agents/wnx/src/engine/providers/mrpe.cpp
@@ -2,26 +2,22 @@
 // provides basic api to start and stop service
 #include "stdafx.h"
 
+#include "providers/mrpe.h"
+
 #include <filesystem>
 #include <regex>
 #include <string>
 #include <string_view>
 #include <tuple>
 
-#include "fmt/format.h"
-
-#include "tools/_raii.h"
-#include "tools/_xlog.h"
-
-#include "common/wtools.h"
-
 #include "cfg.h"
 #include "cma_core.h"
+#include "common/wtools.h"
+#include "fmt/format.h"
 #include "glob_match.h"
-
 #include "logger.h"
-
-#include "providers/mrpe.h"
+#include "tools/_raii.h"
+#include "tools/_xlog.h"
 
 namespace cma::provider {
 
@@ -283,7 +279,9 @@ void MrpeProvider::updateSectionStatus() {
                 FixCrCnForMrpe(data);
                 data += "\n";
 
-                XLOG::t("Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
+                if (cma::cfg::LogMrpeOutput())
+                    XLOG::t(
+                        "Process [{}]\t Pid [{}]\t Code [{}]\n---\n{}\n---\n",
                         wtools::ConvertToUTF8(CmdLine), Pid, Code, data.data());
                 hdr += std::to_string(Code) + " ";
                 accu_ += hdr;



More information about the checkmk-commits mailing list