Reduce logging a bit
Now that there's no --log-level flag, a lot of these daemons are using
just two loggers. In case of the "hardware" service, it's the "sysrepo"
one and the "hardware" one, for example. Do not attempt to log
debug/trace messages via "main", that's useless as they are silently
discarded.
The critical exceptions are still logged via "main", that's OK because
of the default log level.
Also remove some log messages which are really not that informative. I
can imagine they were useful when writing this, but let's hope that we
won't be debugging failures such as "not being able to connect to
D-Bus", etc. These logs were now getting silently discarded anyway.
Change-Id: Ic6e7a8f79d1f2d51992b36c9e53fb568a8727e25
Fixes: 3da1467 ("Get rid of the --log-level option")
diff --git a/src/ietf-hardware/sysrepo/Sysrepo.cpp b/src/ietf-hardware/sysrepo/Sysrepo.cpp
index 2c92237..7b54b33 100644
--- a/src/ietf-hardware/sysrepo/Sysrepo.cpp
+++ b/src/ietf-hardware/sysrepo/Sysrepo.cpp
@@ -29,7 +29,7 @@
auto hwStateValues = m_hwState->process();
utils::valuesToYang(hwStateValues, session, parent);
- spdlog::get("main")->trace("Pushing to sysrepo (JSON): {}", parent->print_mem(LYD_FORMAT::LYD_JSON, 0));
+ spdlog::get("hardware")->trace("Pushing to sysrepo (JSON): {}", parent->print_mem(LYD_FORMAT::LYD_JSON, 0));
return SR_ERR_OK;
},
diff --git a/src/main-firewall.cpp b/src/main-firewall.cpp
index 8cf58a6..973fc27 100644
--- a/src/main-firewall.cpp
+++ b/src/main-firewall.cpp
@@ -51,7 +51,6 @@
spdlog::get("firewall")->set_level(parseLogLevel("Firewall logging", args["--firewall-log-level"]));
spdlog::get("sysrepo")->set_level(parseLogLevel("Sysrepo library", args["--sysrepo-log-level"]));
- spdlog::get("main")->debug("Opening Sysrepo connection");
auto srConn = std::make_shared<sysrepo::Connection>();
auto srSess = std::make_shared<sysrepo::Session>(srConn);
velia::firewall::SysrepoFirewall firewall(srSess, [] (const auto& config) {
@@ -63,8 +62,6 @@
waitUntilSignaled();
- spdlog::get("main")->info("Exiting.");
-
return 0;
} catch (std::exception& e) {
velia::utils::fatalException(spdlog::get("main"), e, "main");
diff --git a/src/main-hardware.cpp b/src/main-hardware.cpp
index a03322e..37bec57 100644
--- a/src/main-hardware.cpp
+++ b/src/main-hardware.cpp
@@ -51,13 +51,11 @@
spdlog::get("sysrepo")->set_level(parseLogLevel("Sysrepo library", args["--sysrepo-log-level"]));
spdlog::get("hardware")->set_level(parseLogLevel("Hardware loggers", args["--hardware-log-level"]));
- spdlog::get("main")->debug("Opening Sysrepo connection");
auto srConn = std::make_shared<sysrepo::Connection>();
auto srSess = std::make_shared<sysrepo::Session>(srConn);
auto srSubscription = std::make_shared<sysrepo::Subscribe>(srSess);
// initialize ietf-hardware
- spdlog::get("main")->debug("Initializing IETFHardware module");
std::shared_ptr<velia::ietf_hardware::IETFHardware> ietfHardware;
if (const auto& appliance = args["--appliance"]) {
ietfHardware = velia::ietf_hardware::create(appliance.asString());
@@ -65,7 +63,6 @@
ietfHardware = std::make_shared<velia::ietf_hardware::IETFHardware>();
}
- spdlog::get("main")->debug("Initializing Sysrepo ietf-hardware callback");
auto sysrepoIETFHardware = velia::ietf_hardware::sysrepo::Sysrepo(srSubscription, ietfHardware);
waitUntilSignaled();
diff --git a/src/main-health.cpp b/src/main-health.cpp
index af6ac3f..262fee5 100644
--- a/src/main-health.cpp
+++ b/src/main-health.cpp
@@ -58,22 +58,20 @@
// output configuration
if (const auto& appliance = args["--appliance"]) {
- spdlog::get("main")->debug("Initializing LED drivers");
+ spdlog::get("health")->debug("Initializing LED drivers");
manager->m_outputSignal.connect(velia::health::createOutput(appliance.asString()));
}
- spdlog::get("main")->debug("All outputs initialized.");
+ spdlog::get("health")->debug("All outputs initialized.");
// input configuration
std::set<std::string> ignoredUnits(args["--systemd-ignore-unit"].asStringList().begin(), args["--systemd-ignore-unit"].asStringList().end());
- spdlog::get("main")->debug("Starting DBus systemd watcher");
+ spdlog::get("health")->debug("Starting DBus systemd watcher");
if (!ignoredUnits.empty()) {
- spdlog::get("main")->debug("Systemd input will ignore changes of the following units: {}", args["--systemd-ignore-unit"]);
+ spdlog::get("health")->debug("Systemd input will ignore changes of the following units: {}", args["--systemd-ignore-unit"]);
}
auto inputSystemdDbus = std::make_shared<velia::health::DbusSystemdInput>(manager, ignoredUnits, *g_dbusConnection);
- spdlog::get("main")->debug("All inputs initialized.");
-
DBUS_EVENTLOOP_END;
return 0;
diff --git a/src/main-system.cpp b/src/main-system.cpp
index 9128d77..5a1d47b 100644
--- a/src/main-system.cpp
+++ b/src/main-system.cpp
@@ -53,14 +53,12 @@
try {
spdlog::get("sysrepo")->set_level(parseLogLevel("Sysrepo library", args["--sysrepo-log-level"]));
- spdlog::get("main")->debug("Opening Sysrepo connection");
auto srConn = std::make_shared<sysrepo::Connection>();
auto srSess = std::make_shared<sysrepo::Session>(srConn);
DBUS_EVENTLOOP_START
// initialize ietf-system
- spdlog::get("main")->debug("Initializing Sysrepo for system models");
auto sysrepoIETFSystem = velia::system::IETFSystem(srSess, "/etc/os-release");
auto dbusConnection = sdbus::createConnection(); // second connection for RAUC (for calling methods).
diff --git a/src/main.h b/src/main.h
index 7c60acb..7e787c0 100644
--- a/src/main.h
+++ b/src/main.h
@@ -10,7 +10,6 @@
std::thread g_eventLoop;
#define DBUS_EVENTLOOP_START \
- spdlog::get("main")->debug("Opening DBus connection"); \
g_dbusConnection = sdbus::createSystemBusConnection(); \
/* Gracefully leave dbus event loop on SIGTERM */ \
struct sigaction sigact; \
@@ -19,9 +18,7 @@
sigact.sa_flags = SA_SIGINFO; \
sigact.sa_handler = [](int) { g_dbusConnection->leaveEventLoop(); }; \
sigaction(SIGTERM, &sigact, nullptr); \
- spdlog::get("main")->debug("Starting DBus event loop"); \
g_eventLoop = std::thread([] { g_dbusConnection->enterEventLoop(); }); \
#define DBUS_EVENTLOOP_END \
- g_eventLoop.join(); \
- spdlog::get("main")->debug("Shutting down");
+ g_eventLoop.join();
diff --git a/src/utils/sysrepo.cpp b/src/utils/sysrepo.cpp
index dc97c52..bd1b506 100644
--- a/src/utils/sysrepo.cpp
+++ b/src/utils/sysrepo.cpp
@@ -54,8 +54,6 @@
void valuesToYang(const std::map<std::string, std::string>& values, std::shared_ptr<::sysrepo::Session> session, std::shared_ptr<libyang::Data_Node>& parent)
{
for (const auto& [propertyName, value] : values) {
- spdlog::get("main")->trace("propertyName: {}, value: {}", propertyName, value.c_str());
-
if (!parent) {
parent = std::make_shared<libyang::Data_Node>(
session->get_context(),
diff --git a/src/utils/waitUntilSignalled.cpp b/src/utils/waitUntilSignalled.cpp
index 70fcca5..7c1cd08 100644
--- a/src/utils/waitUntilSignalled.cpp
+++ b/src/utils/waitUntilSignalled.cpp
@@ -6,7 +6,6 @@
*/
#include <csignal>
-#include <spdlog/spdlog.h>
#include <unistd.h>
#include "waitUntilSignalled.h"
@@ -15,5 +14,4 @@
signal(SIGTERM, [](int) {});
signal(SIGINT, [](int) {});
pause();
- spdlog::get("main")->debug("Shutting down");
}