Skip to content

Commit

Permalink
Fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev authored and RickiNano committed Jul 5, 2024
1 parent a9e034f commit 6a4a31b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions nano/lib/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -47,7 +47,7 @@ void nano::set_file_descriptor_limit (std::size_t limit)
fd_limit.rlim_cur = std::min (static_cast<rlim_t> (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
Expand Down
1 change: 1 addition & 0 deletions nano/nano_node/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6a4a31b

Please sign in to comment.