From fa9593f5c88f751988f7e643a27b69422a69bbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:44:29 +0200 Subject: [PATCH] Signal manager logging --- nano/lib/logging_enums.hpp | 1 + nano/lib/signal_manager.cpp | 17 +++++++++-------- nano/lib/signal_manager.hpp | 9 +++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/nano/lib/logging_enums.hpp b/nano/lib/logging_enums.hpp index 79f4df8dec..7392320bc8 100644 --- a/nano/lib/logging_enums.hpp +++ b/nano/lib/logging_enums.hpp @@ -75,6 +75,7 @@ enum class type rep_tiers, syn_cookies, thread_runner, + signal_manager, // bootstrap bulk_pull_client, diff --git a/nano/lib/signal_manager.cpp b/nano/lib/signal_manager.cpp index d84fe153a1..b6075f81a3 100644 --- a/nano/lib/signal_manager.cpp +++ b/nano/lib/signal_manager.cpp @@ -46,14 +46,16 @@ void nano::signal_manager::register_signal_handler (int signum, std::functionclear (); } - - descriptor.sigman.log (boost::str (boost::format ("Signal processed: %d") % signum)); } else { - descriptor.sigman.log (boost::str (boost::format ("Signal error: %d (%s)") % error.value () % error.message ())); + logger.debug (nano::log::type::signal_manager, "Signal error: {} ({})", ec.message (), to_signal_name (signum)); } } diff --git a/nano/lib/signal_manager.hpp b/nano/lib/signal_manager.hpp index 926fe7296f..333861be3a 100644 --- a/nano/lib/signal_manager.hpp +++ b/nano/lib/signal_manager.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -51,18 +52,14 @@ class signal_manager final bool repeat; }; - /** - * Logging function of signal manager. It does nothing at the moment, it throws away the log. - * I expect to revisit this in the future. It also makes it easy to manually introduce logs, if needed temporarily. - */ - void log (std::string const &){}; - /** * This is the actual handler that is registered with boost asio. * It calls the caller supplied function (if one is given) and sets the handler to repeat (or not). */ static void base_handler (nano::signal_manager::signal_descriptor descriptor, boost::system::error_code const & error, int signum); + nano::logger logger; + /** boost asio context to use */ boost::asio::io_context ioc;