From 9d47208735741c25d939b4655fba6f3e5e5692e3 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Mon, 9 Aug 2021 09:56:51 +0100 Subject: [PATCH] Removing unnecessary check for running within unit test context and associated static instantiation of network_constants. No appreciable difference in unit test speed. --- nano/node/logging.cpp | 50 +++++++++++++++++++----------------------- nano/secure/ledger.cpp | 1 - 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/nano/node/logging.cpp b/nano/node/logging.cpp index 512319f9..2b7d007f 100644 --- a/nano/node/logging.cpp +++ b/nano/node/logging.cpp @@ -36,38 +36,34 @@ void nano::logging::init (boost::filesystem::path const & application_path_a) boost::log::add_console_log (std::cerr, boost::log::keywords::format = format_with_timestamp); } - nano::network_constants network_constants; - if (!network_constants.is_dev_network ()) - { #ifdef BOOST_WINDOWS - if (nano::event_log_reg_entry_exists () || nano::is_windows_elevated ()) - { - static auto event_sink = boost::make_shared> (boost::log::keywords::log_name = "Nano", boost::log::keywords::log_source = "Nano"); - event_sink->set_formatter (format); - - // Currently only mapping sys log errors - boost::log::sinks::event_log::custom_event_type_mapping mapping ("Severity"); - mapping[nano::severity_level::error] = boost::log::sinks::event_log::error; - event_sink->locked_backend ()->set_event_type_mapper (mapping); - - // Only allow messages or error or greater severity to the event log - event_sink->set_filter (severity >= nano::severity_level::error); - boost::log::core::get ()->add_sink (event_sink); - } -#else - static auto sys_sink = boost::make_shared> (boost::log::keywords::facility = boost::log::sinks::syslog::user, boost::log::keywords::use_impl = boost::log::sinks::syslog::impl_types::native); - sys_sink->set_formatter (format); + if (nano::event_log_reg_entry_exists () || nano::is_windows_elevated ()) + { + static auto event_sink = boost::make_shared> (boost::log::keywords::log_name = "Nano", boost::log::keywords::log_source = "Nano"); + event_sink->set_formatter (format); // Currently only mapping sys log errors - boost::log::sinks::syslog::custom_severity_mapping mapping ("Severity"); - mapping[nano::severity_level::error] = boost::log::sinks::syslog::error; - sys_sink->locked_backend ()->set_severity_mapper (mapping); + boost::log::sinks::event_log::custom_event_type_mapping mapping ("Severity"); + mapping[nano::severity_level::error] = boost::log::sinks::event_log::error; + event_sink->locked_backend ()->set_event_type_mapper (mapping); - // Only allow messages or error or greater severity to the sys log - sys_sink->set_filter (severity >= nano::severity_level::error); - boost::log::core::get ()->add_sink (sys_sink); -#endif + // Only allow messages or error or greater severity to the event log + event_sink->set_filter (severity >= nano::severity_level::error); + boost::log::core::get ()->add_sink (event_sink); } +#else + static auto sys_sink = boost::make_shared> (boost::log::keywords::facility = boost::log::sinks::syslog::user, boost::log::keywords::use_impl = boost::log::sinks::syslog::impl_types::native); + sys_sink->set_formatter (format); + + // Currently only mapping sys log errors + boost::log::sinks::syslog::custom_severity_mapping mapping ("Severity"); + mapping[nano::severity_level::error] = boost::log::sinks::syslog::error; + sys_sink->locked_backend ()->set_severity_mapper (mapping); + + // Only allow messages or error or greater severity to the sys log + sys_sink->set_filter (severity >= nano::severity_level::error); + boost::log::core::get ()->add_sink (sys_sink); +#endif //clang-format off #if BOOST_VERSION < 107000 diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index ebd584c6..0f15c0fc 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -863,7 +863,6 @@ nano::uint128_t nano::ledger::account_pending (nano::transaction const & transac nano::process_return nano::ledger::process (nano::write_transaction const & transaction_a, nano::block & block_a, nano::signature_verification verification) { - static nano::network_constants network_constants; debug_assert (!constants.work.validate_entry (block_a) || constants.genesis == nano::dev::genesis); ledger_processor processor (*this, transaction_a, verification); block_a.visit (processor);