From 6a4a31b6509e9b5f488d77f1a1b8ef7b70dd69b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:35:36 +0200 Subject: [PATCH] Fix logging --- nano/lib/utility.cpp | 4 ++-- nano/nano_node/daemon.cpp | 1 + nano/nano_node/entry.cpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nano/lib/utility.cpp b/nano/lib/utility.cpp index 869828bd04..f1a0ca908e 100644 --- a/nano/lib/utility.cpp +++ b/nano/lib/utility.cpp @@ -35,7 +35,7 @@ void nano::set_file_descriptor_limit (std::size_t limit) rlimit fd_limit{}; if (-1 == getrlimit (RLIMIT_NOFILE, &fd_limit)) { - std::cerr << "Unable to get current limits for the number of open file descriptors: " << std::strerror (errno); + std::cerr << "WARNING: Unable to get current limits for the number of open file descriptors: " << std::strerror (errno); return; } @@ -47,7 +47,7 @@ void nano::set_file_descriptor_limit (std::size_t limit) fd_limit.rlim_cur = std::min (static_cast (limit), fd_limit.rlim_max); if (-1 == setrlimit (RLIMIT_NOFILE, &fd_limit)) { - std::cerr << "Unable to set limits for the number of open file descriptors: " << std::strerror (errno); + std::cerr << "WARNING: Unable to set limits for the number of open file descriptors: " << std::strerror (errno); return; } #endif diff --git a/nano/nano_node/daemon.cpp b/nano/nano_node/daemon.cpp index 3b7de4a402..45eaea5509 100644 --- a/nano/nano_node/daemon.cpp +++ b/nano/nano_node/daemon.cpp @@ -103,6 +103,7 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag // Print info about number of logical cores detected, those are used to decide how many IO, worker and signature checker threads to spawn logger.info (nano::log::type::daemon, "Hardware concurrency: {} ( configured: {} )", std::thread::hardware_concurrency (), nano::hardware_concurrency ()); + logger.info (nano::log::type::daemon, "File descriptors limit: {}", nano::get_file_descriptor_limit ()); // for the daemon start up, if the user hasn't specified a port in // the config, we must use the default peering port for the network diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index ce39a0a6eb..994e893eba 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -64,12 +64,12 @@ int main (int argc, char * const * argv) nano::set_umask (); // Make sure the process umask is set before any files are created nano::logger::initialize (nano::log_config::cli_default ()); + // Increase file descriptor limit nano::set_file_descriptor_limit (OPEN_FILE_DESCRIPTORS_LIMIT); auto const file_descriptor_limit = nano::get_file_descriptor_limit (); - nano::default_logger ().info (nano::log::type::daemon, "File descriptors limit: {}", file_descriptor_limit); if (file_descriptor_limit < OPEN_FILE_DESCRIPTORS_LIMIT) { - nano::default_logger ().warn (nano::log::type::daemon, "File descriptors limit is lower than the {} recommended. Node was unable to change it.", OPEN_FILE_DESCRIPTORS_LIMIT); + std::cerr << "WARNING: Current file descriptor limit of " << file_descriptor_limit << " is lower than the " << OPEN_FILE_DESCRIPTORS_LIMIT << " recommended. Node was unable to change it." << std::endl; } nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;