From addcd248a8fa2b72f918eb29ec3850da7fb1c5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:10:26 +0100 Subject: [PATCH] Remove legacy logger --- CMakeLists.txt | 4 - nano/core_test/block_store.cpp | 2 +- nano/core_test/bootstrap.cpp | 36 +- nano/core_test/confirmation_height.cpp | 1 - nano/core_test/core_test_main.cc | 4 - nano/core_test/logger.cpp | 98 +---- nano/core_test/network.cpp | 16 +- nano/core_test/node.cpp | 89 +++-- nano/core_test/toml.cpp | 58 --- nano/core_test/unchecked_map.cpp | 1 - nano/core_test/work_pool.cpp | 3 - nano/lib/CMakeLists.txt | 3 - nano/lib/logger_mt.hpp | 139 ------- nano/lib/logging.hpp | 8 + nano/nano_node/daemon.cpp | 2 - nano/nano_node/entry.cpp | 9 - nano/nano_rpc/entry.cpp | 20 +- nano/nano_wallet/entry.cpp | 2 - nano/node/CMakeLists.txt | 4 - nano/node/blockprocessor.cpp | 2 +- nano/node/bootstrap/bootstrap_connections.cpp | 23 +- nano/node/confirmation_height_bounded.cpp | 2 - nano/node/confirmation_height_bounded.hpp | 2 - nano/node/confirmation_height_processor.cpp | 1 - nano/node/confirmation_height_unbounded.cpp | 2 - nano/node/confirmation_height_unbounded.hpp | 2 - nano/node/ipc/ipc_server.cpp | 2 - nano/node/logging.cpp | 344 ------------------ nano/node/logging.hpp | 105 ------ nano/node/node.cpp | 7 +- nano/node/node.hpp | 4 +- nano/node/nodeconfig.cpp | 15 +- nano/node/nodeconfig.hpp | 4 +- nano/node/vote_processor.cpp | 5 +- nano/rpc/rpc_connection.cpp | 1 - nano/rpc/rpc_connection.hpp | 1 - nano/rpc/rpc_handler.cpp | 1 - nano/rpc/rpc_handler.hpp | 1 - nano/rpc_test/rpc.cpp | 3 +- nano/slow_test/node.cpp | 4 +- nano/test_common/CMakeLists.txt | 2 +- nano/test_common/ledger.hpp | 1 - nano/test_common/network.cpp | 2 +- nano/test_common/system.cpp | 3 +- nano/test_common/system.hpp | 1 - nano/test_common/testutil.hpp | 50 --- 46 files changed, 107 insertions(+), 982 deletions(-) delete mode 100644 nano/lib/logger_mt.hpp delete mode 100644 nano/node/logging.cpp delete mode 100644 nano/node/logging.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a1bd6a5085..391891da03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,10 +483,6 @@ include_directories(${BOOST_LIBRARY_INCLUDES}) add_library(Boost::stacktrace ALIAS boost_stacktrace_basic) add_definitions(-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) -# Workaround for GitHub builders which do not appear to have the Windows Message -# Compiler mc.exe -add_definitions(-DBOOST_LOG_WITHOUT_EVENT_LOG) - # Workaround for missing reference errata in the boost property_tree module target_link_libraries(boost_property_tree INTERFACE Boost::any) target_link_libraries(boost_property_tree INTERFACE Boost::format) diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index eef550e611..bfd16843a5 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/nano/core_test/bootstrap.cpp b/nano/core_test/bootstrap.cpp index 739b4e91a0..ca9f90177f 100644 --- a/nano/core_test/bootstrap.cpp +++ b/nano/core_test/bootstrap.cpp @@ -283,7 +283,7 @@ TEST (bulk_pull, count_limit) TEST (bootstrap_processor, DISABLED_process_none) { nano::test::system system (1); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); auto done (false); node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint (), false); @@ -338,7 +338,7 @@ TEST (bootstrap_processor, process_two) ASSERT_NE (hash1, hash3); ASSERT_NE (hash2, hash3); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); node1->bootstrap_initiator.bootstrap (node0->network.endpoint (), false); ASSERT_NE (node1->latest (nano::dev::genesis_key.pub), node0->latest (nano::dev::genesis_key.pub)); @@ -384,7 +384,7 @@ TEST (bootstrap_processor, process_state) ASSERT_EQ (nano::process_result::progress, node0->process (*block2).code); config.peering_port = system.get_available_port (); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); ASSERT_EQ (node0->latest (nano::dev::genesis_key.pub), block2->hash ()); ASSERT_NE (node1->latest (nano::dev::genesis_key.pub), block2->hash ()); node1->bootstrap_initiator.bootstrap (node0->network.endpoint (), false); @@ -415,7 +415,7 @@ TEST (bootstrap_processor, process_new) nano::uint128_t balance2 (node1->balance (key2.pub)); ASSERT_TIMELY (10s, node1->block_confirmed (send->hash ()) && node1->block_confirmed (receive->hash ()) && node1->active.empty () && node2->active.empty ()); // All blocks should be propagated & confirmed - auto node3 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node3 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node3->init_error ()); node3->bootstrap_initiator.bootstrap (node1->network.endpoint (), false); ASSERT_TIMELY (10s, node3->balance (key2.pub) == balance2); @@ -468,7 +468,7 @@ TEST (bootstrap_processor, pull_diamond) .work (*system.work.generate (send1->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node0->process (*receive).code); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); node1->bootstrap_initiator.bootstrap (node0->network.endpoint (), false); ASSERT_TIMELY (10s, node1->balance (nano::dev::genesis_key.pub) == 100); @@ -529,7 +529,7 @@ TEST (bootstrap_processor, DISABLED_push_diamond) config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node0 (system.add_node (config)); nano::keypair key; - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); auto wallet1 (node1->wallets.create (100)); wallet1->insert_adhoc (nano::dev::genesis_key.prv); @@ -662,7 +662,7 @@ TEST (bootstrap_processor, push_one) config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node0 (system.add_node (config)); nano::keypair key1; - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); auto wallet (node1->wallets.create (nano::random_wallet_id ())); ASSERT_NE (nullptr, wallet); wallet->insert_adhoc (nano::dev::genesis_key.prv); @@ -736,7 +736,7 @@ TEST (bootstrap_processor, lazy_hash) node0->block_processor.add (receive2); node0->block_processor.flush (); // Start lazy bootstrap with last block in chain known - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); nano::test::establish_tcp (system, *node1, node0->network.endpoint ()); node1->bootstrap_initiator.bootstrap_lazy (receive2->hash (), true); { @@ -810,7 +810,7 @@ TEST (bootstrap_processor, lazy_hash_bootstrap_id) node0->block_processor.add (receive2); node0->block_processor.flush (); // Start lazy bootstrap with last block in chain known - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); nano::test::establish_tcp (system, *node1, node0->network.endpoint ()); node1->bootstrap_initiator.bootstrap_lazy (receive2->hash (), true, "123456"); { @@ -1052,7 +1052,7 @@ TEST (bootstrap_processor, lazy_max_pull_count) node0->block_processor.add (change3); node0->block_processor.flush (); // Start lazy bootstrap with last block in chain known - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); nano::test::establish_tcp (system, *node1, node0->network.endpoint ()); node1->bootstrap_initiator.bootstrap_lazy (change3->hash ()); // Check processed blocks @@ -1390,7 +1390,7 @@ TEST (bootstrap_processor, lazy_cancel) .build_shared (); // Start lazy bootstrap with last block in chain known - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); nano::test::establish_tcp (system, *node1, node0->network.endpoint ()); node1->bootstrap_initiator.bootstrap_lazy (send1->hash (), true); // Start "confirmed" block bootstrap { @@ -1465,7 +1465,7 @@ TEST (bootstrap_processor, wallet_lazy_frontier) node0->block_processor.add (receive2); node0->block_processor.flush (); // Start wallet lazy bootstrap - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); nano::test::establish_tcp (system, *node1, node0->network.endpoint ()); auto wallet (node1->wallets.create (nano::random_wallet_id ())); ASSERT_NE (nullptr, wallet); @@ -1911,14 +1911,14 @@ TEST (frontier_req, confirmed_frontier) TEST (bulk, genesis) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_lazy_bootstrap = true; auto node1 = system.add_node (config, node_flags); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node2->init_error ()); nano::block_hash latest1 (node1->latest (nano::dev::genesis_key.pub)); nano::block_hash latest2 (node2->latest (nano::dev::genesis_key.pub)); @@ -1938,14 +1938,14 @@ TEST (bulk, genesis) TEST (bulk, offline_send) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_lazy_bootstrap = true; auto node1 = system.add_node (config, node_flags); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node2->init_error ()); node2->start (); system.nodes.push_back (node2); @@ -1980,7 +1980,7 @@ TEST (bulk, offline_send) TEST (bulk, DISABLED_genesis_pruning) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; config.enable_voting = false; // Remove after allowing pruned voting nano::node_flags node_flags; @@ -1991,7 +1991,7 @@ TEST (bulk, DISABLED_genesis_pruning) auto node1 = system.add_node (config, node_flags); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); node_flags.enable_pruning = false; - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); ASSERT_FALSE (node2->init_error ()); nano::block_hash latest1 (node1->latest (nano::dev::genesis_key.pub)); nano::block_hash latest2 (node2->latest (nano::dev::genesis_key.pub)); diff --git a/nano/core_test/confirmation_height.cpp b/nano/core_test/confirmation_height.cpp index e0a65a3a92..72f8737e00 100644 --- a/nano/core_test/confirmation_height.cpp +++ b/nano/core_test/confirmation_height.cpp @@ -2103,7 +2103,6 @@ TEST (confirmation_height, unbounded_block_cache_iteration) TEST (confirmation_height, pruned_source) { nano::nlogger logger; - nano::logging logging; auto path (nano::unique_path ()); auto store = nano::make_store (logger, path, nano::dev::constants); ASSERT_TRUE (!store->init_error ()); diff --git a/nano/core_test/core_test_main.cc b/nano/core_test/core_test_main.cc index 158256de69..2710b0f8a6 100644 --- a/nano/core_test/core_test_main.cc +++ b/nano/core_test/core_test_main.cc @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -24,9 +23,6 @@ GTEST_API_ int main (int argc, char ** argv) nano::set_file_descriptor_limit (OPEN_FILE_DESCRIPTORS_LIMIT); nano::force_nano_dev_network (); nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard; - // Setting up logging so that there aren't any piped to standard output. - nano::logging logging; - logging.init (nano::unique_path ()); testing::InitGoogleTest (&argc, argv); auto res = RUN_ALL_TESTS (); nano::test::cleanup_dev_directories_on_exit (); diff --git a/nano/core_test/logger.cpp b/nano/core_test/logger.cpp index 663cfac2db..4398afab8d 100644 --- a/nano/core_test/logger.cpp +++ b/nano/core_test/logger.cpp @@ -1,5 +1,4 @@ -#include -#include + #include #include @@ -13,98 +12,7 @@ using namespace std::chrono_literals; -TEST (logger, changing_time_interval) -{ - auto path1 (nano::unique_path ()); - nano::logging logging; - logging.init (path1); - logging.min_time_between_log_output = 0ms; - nano::logger_mt my_logger (logging.min_time_between_log_output); - auto error (my_logger.try_log ("logger.changing_time_interval1")); - ASSERT_FALSE (error); - my_logger.min_log_delta = 20s; - error = my_logger.try_log ("logger, changing_time_interval2"); - ASSERT_TRUE (error); -} - -TEST (logger, try_log) +TEST (logger, basic) { - auto path1 (nano::unique_path ()); - std::stringstream ss; - nano::test::boost_log_cerr_redirect redirect_cerr (ss.rdbuf ()); - nano::logger_mt my_logger (100ms); - auto output1 = "logger.try_log1"; - auto error (my_logger.try_log (output1)); - ASSERT_FALSE (error); - auto output2 = "logger.try_log2"; - error = my_logger.try_log (output2); - ASSERT_TRUE (error); // Fails as it is occuring too soon - - // Sleep for a bit and then confirm - std::this_thread::sleep_for (100ms); - error = my_logger.try_log (output2); - ASSERT_FALSE (error); - - std::string str; - std::getline (ss, str, '\n'); - ASSERT_STREQ (str.c_str (), output1); - std::getline (ss, str, '\n'); - ASSERT_STREQ (str.c_str (), output2); -} - -TEST (logger, always_log) -{ - auto path1 (nano::unique_path ()); - std::stringstream ss; - nano::test::boost_log_cerr_redirect redirect_cerr (ss.rdbuf ()); - nano::logger_mt my_logger (20s); // Make time interval effectively unreachable - auto output1 = "logger.always_log1"; - auto error (my_logger.try_log (output1)); - ASSERT_FALSE (error); - - // Time is too soon after, so it won't be logged - auto output2 = "logger.always_log2"; - error = my_logger.try_log (output2); - ASSERT_TRUE (error); - - // Force it to be logged - my_logger.always_log (output2); - - std::string str; - std::getline (ss, str, '\n'); - ASSERT_STREQ (str.c_str (), output1); - std::getline (ss, str, '\n'); - ASSERT_STREQ (str.c_str (), output2); -} - -TEST (logger, stable_filename) -{ - auto path (nano::unique_path ()); - nano::logging logging; - - // Releasing allows setting up logging again - logging.release_file_sink (); - - logging.stable_log_filename = true; - logging.init (path); - - nano::logger_mt logger (logging.min_time_between_log_output); - logger.always_log ("stable1"); - - auto log_file = path / "log" / "node.log"; - -#if BOOST_VERSION >= 107000 - EXPECT_TRUE (std::filesystem::exists (log_file)); - // Try opening it again - logging.release_file_sink (); - logging.init (path); - logger.always_log ("stable2"); -#else - // When using Boost < 1.70 , behavior is reverted to not using the stable filename - EXPECT_FALSE (std::filesystem::exists (log_file)); -#endif - - // Reset the logger - logging.release_file_sink (); - nano::logging ().init (path); + // TODO } diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index c9ebbcd90f..abdd8f9560 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -58,7 +58,7 @@ TEST (network, construction_with_specified_port) { nano::test::system system{}; auto const port = system.get_available_port (/* do not allow 0 port */ false); - auto const node = system.add_node (nano::node_config{ port, system.logging }); + auto const node = system.add_node (nano::node_config{ port }); EXPECT_EQ (port, node->network.port); EXPECT_EQ (port, node->network.endpoint ().port ()); EXPECT_EQ (port, node->tcp_listener.endpoint ().port ()); @@ -79,7 +79,7 @@ TEST (network, send_node_id_handshake_tcp) nano::test::system system (1); auto node0 (system.nodes[0]); ASSERT_EQ (0, node0->network.size ()); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); node1->start (); system.nodes.push_back (node1); auto initial (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in)); @@ -157,7 +157,7 @@ TEST (network, multi_keepalive) nano::test::system system (1); auto node0 = system.nodes[0]; ASSERT_EQ (0, node0->network.size ()); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); node1->start (); system.nodes.push_back (node1); @@ -165,7 +165,7 @@ TEST (network, multi_keepalive) ASSERT_EQ (0, node0->network.size ()); node1->network.tcp_channels.start_tcp (node0->network.endpoint ()); ASSERT_TIMELY (10s, node0->network.size () == 1 && node0->stats.count (nano::stat::type::message, nano::stat::detail::keepalive) >= 1); - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node2->init_error ()); node2->start (); system.nodes.push_back (node2); @@ -749,7 +749,7 @@ TEST (network, peer_max_tcp_attempts) auto node = system.add_node (node_flags); for (auto i (0); i < node->network_params.network.max_peers_per_ip; ++i) { - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); node2->start (); system.nodes.push_back (node2); // Start TCP attempt @@ -826,7 +826,7 @@ TEST (network, duplicate_revert_publish) nano::uint128_t digest; ASSERT_FALSE (node.network.publish_filter.apply (bytes.data (), bytes.size (), &digest)); ASSERT_TRUE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); - auto other_node (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto other_node (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); other_node->start (); system.nodes.push_back (other_node); auto channel = nano::test::establish_tcp (system, *other_node, node.network.endpoint ()); @@ -957,7 +957,7 @@ TEST (network, tcp_no_connect_excluded_peers) nano::test::system system (1); auto node0 (system.nodes[0]); ASSERT_EQ (0, node0->network.size ()); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); node1->start (); system.nodes.push_back (node1); auto endpoint1_tcp (nano::transport::map_endpoint_to_tcp (node1->network.endpoint ())); @@ -1058,7 +1058,7 @@ TEST (network, cleanup_purge) nano::test::system system (1); auto & node1 (*system.nodes[0]); - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); node2->start (); system.nodes.push_back (node2); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index aa7d8e82ee..07b2fa5cd1 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -72,10 +72,8 @@ TEST (node, block_store_path_failure) nano::test::system system; auto service (boost::make_shared ()); auto path (nano::unique_path ()); - nano::logging logging; - logging.init (path); nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; - auto node (std::make_shared (*service, system.get_available_port (), path, logging, pool)); + auto node (std::make_shared (*service, system.get_available_port (), path, pool)); ASSERT_TRUE (node->wallets.items.empty ()); node->stop (); } @@ -105,7 +103,6 @@ TEST (node, password_fanout) auto path (nano::unique_path ()); nano::node_config config; config.peering_port = system.get_available_port (); - config.logging.init (path); nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; config.password_fanout = 10; nano::node node (io_ctx, path, config, pool); @@ -271,7 +268,7 @@ TEST (node, node_receive_quorum) TEST (node, auto_bootstrap) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; @@ -283,7 +280,7 @@ TEST (node, auto_bootstrap) auto send1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, node0->config.receive_minimum.number ())); ASSERT_NE (nullptr, send1); ASSERT_TIMELY (10s, node0->balance (key2.pub) == node0->config.receive_minimum.number ()); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); ASSERT_FALSE (node1->init_error ()); node1->start (); system.nodes.push_back (node1); @@ -303,7 +300,7 @@ TEST (node, auto_bootstrap) TEST (node, auto_bootstrap_reverse) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; @@ -312,7 +309,7 @@ TEST (node, auto_bootstrap_reverse) nano::keypair key2; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); system.wallet (0)->insert_adhoc (key2.prv); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); ASSERT_FALSE (node1->init_error ()); ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, node0->config.receive_minimum.number ())); node1->start (); @@ -324,14 +321,14 @@ TEST (node, auto_bootstrap_reverse) TEST (node, auto_bootstrap_age) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_lazy_bootstrap = true; node_flags.bootstrap_interval = 1; auto node0 = system.add_node (config, node_flags); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work, node_flags)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work, node_flags)); ASSERT_FALSE (node1->init_error ()); node1->start (); system.nodes.push_back (node1); @@ -421,7 +418,7 @@ TEST (node, search_receivable_multiple) TEST (node, search_receivable_confirmed) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node = system.add_node (node_config); nano::keypair key2; @@ -455,12 +452,12 @@ TEST (node, search_receivable_confirmed) TEST (node, search_receivable_pruned) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node1 = system.add_node (node_config); nano::node_flags node_flags; node_flags.enable_pruning = true; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.enable_voting = false; // Remove after allowing pruned voting auto node2 = system.add_node (config, node_flags); nano::keypair key2; @@ -554,9 +551,7 @@ TEST (node, confirm_locked) TEST (node_config, random_rep) { auto path (nano::unique_path ()); - nano::logging logging1; - logging1.init (path); - nano::node_config config1 (100, logging1); + nano::node_config config1 (100); auto rep (config1.random_representative ()); ASSERT_NE (config1.preconfigured_representatives.end (), std::find (config1.preconfigured_representatives.begin (), config1.preconfigured_representatives.end (), rep)); } @@ -766,7 +761,7 @@ TEST (node, fork_multi_flip) auto type = nano::transport::transport_type::tcp; nano::test::system system; nano::node_flags node_flags; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config, node_flags, type)); node_config.peering_port = system.get_available_port (); @@ -839,13 +834,13 @@ TEST (node, fork_bootstrap_flip) nano::test::system system; nano::test::system system0; nano::test::system system1; - nano::node_config config0{ system.get_available_port (), system0.logging }; + nano::node_config config0{ system.get_available_port () }; config0.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_lazy_bootstrap = true; auto & node1 = *system0.add_node (config0, node_flags); - nano::node_config config1 (system.get_available_port (), system1.logging); + nano::node_config config1 (system.get_available_port ()); auto & node2 = *system1.add_node (config1, node_flags); system0.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::block_hash latest = node1.latest (nano::dev::genesis_key.pub); @@ -1251,7 +1246,7 @@ TEST (node, DISABLED_broadcast_elected) auto type = nano::transport::transport_type::tcp; nano::node_flags node_flags; nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node0 = system.add_node (node_config, node_flags, type); node_config.peering_port = system.get_available_port (); @@ -1377,7 +1372,7 @@ TEST (node, DISABLED_broadcast_elected) TEST (node, rep_self_vote) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.online_weight_minimum = std::numeric_limits::max (); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node0 = system.add_node (node_config); @@ -1475,10 +1470,10 @@ TEST (node, DISABLED_bootstrap_bulk_push) nano::test::system system; nano::test::system system0; nano::test::system system1; - nano::node_config config0 (system.get_available_port (), system0.logging); + nano::node_config config0 (system.get_available_port ()); config0.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node0 (system0.add_node (config0)); - nano::node_config config1 (system.get_available_port (), system1.logging); + nano::node_config config1 (system.get_available_port ()); config1.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node1 (system1.add_node (config1)); nano::keypair key0; @@ -1515,7 +1510,7 @@ TEST (node, DISABLED_bootstrap_bulk_push) TEST (node, bootstrap_fork_open) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); auto node0 = system.add_node (node_config); node_config.peering_port = system.get_available_port (); auto node1 = system.add_node (node_config); @@ -1688,7 +1683,7 @@ TEST (node, rep_weight) { nano::test::system system; auto add_node = [&system] { - auto node = std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work); + auto node = std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work); node->start (); system.nodes.push_back (node); return node; @@ -1858,7 +1853,7 @@ TEST (node, rep_remove) ASSERT_TIMELY (5s, searching_node.rep_crawler.representative_count () == 0); // Add working node for genesis representative - auto node_genesis_rep = system.add_node (nano::node_config (system.get_available_port (), system.logging)); + auto node_genesis_rep = system.add_node (nano::node_config (system.get_available_port ())); system.wallet (1)->insert_adhoc (nano::dev::genesis_key.prv); auto channel_genesis_rep (searching_node.network.find_node_id (node_genesis_rep->get_node_id ())); ASSERT_NE (nullptr, channel_genesis_rep); @@ -1869,7 +1864,7 @@ TEST (node, rep_remove) ASSERT_TIMELY (10s, searching_node.rep_crawler.representative_count () == 1); // Start a node for Rep2 and wait until it is connected - auto node_rep2 (std::make_shared (system.io_ctx, nano::unique_path (), nano::node_config (system.get_available_port (), system.logging), system.work)); + auto node_rep2 (std::make_shared (system.io_ctx, nano::unique_path (), nano::node_config (system.get_available_port ()), system.work)); node_rep2->start (); searching_node.network.tcp_channels.start_tcp (node_rep2->network.endpoint ()); std::shared_ptr channel_rep2; @@ -1910,7 +1905,7 @@ TEST (node, no_voting) { nano::test::system system (1); auto & node0 (*system.nodes[0]); - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.enable_voting = false; system.add_node (node_config); @@ -2234,7 +2229,7 @@ TEST (node, confirm_quorum) TEST (node, local_votes_cache) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; node_config.receive_minimum = nano::dev::constants.genesis_amount; auto & node (*system.add_node (node_config)); @@ -2322,7 +2317,7 @@ TEST (node, local_votes_cache) TEST (node, DISABLED_local_votes_cache_batch) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); ASSERT_GE (node.network_params.voting.max_cache, 2); @@ -2395,7 +2390,7 @@ TEST (node, DISABLED_local_votes_cache_batch) TEST (node, local_votes_cache_generate_new_vote) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); @@ -2448,7 +2443,7 @@ TEST (node, local_votes_cache_fork) node_flags.disable_lazy_bootstrap = true; node_flags.disable_legacy_bootstrap = true; node_flags.disable_wallet_bootstrap = true; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config, node_flags)); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); @@ -2699,7 +2694,7 @@ TEST (node, DISABLED_vote_by_hash_epoch_block_republish) TEST (node, epoch_conflict_confirm) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node0 = *system.add_node (node_config); node_config.peering_port = system.get_available_port (); @@ -3030,7 +3025,7 @@ TEST (node, block_processor_full) nano::node_flags node_flags; node_flags.force_use_write_database_queue = true; node_flags.block_processor_full_size = 3; - auto & node = *system.add_node (nano::node_config (system.get_available_port (), system.logging), node_flags); + auto & node = *system.add_node (nano::node_config (system.get_available_port ()), node_flags); nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) @@ -3075,7 +3070,7 @@ TEST (node, block_processor_half_full) nano::node_flags node_flags; node_flags.block_processor_full_size = 6; node_flags.force_use_write_database_queue = true; - auto & node = *system.add_node (nano::node_config (system.get_available_port (), system.logging), node_flags); + auto & node = *system.add_node (nano::node_config (system.get_available_port ()), node_flags); nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) @@ -3167,7 +3162,7 @@ TEST (node, peers) auto node1 (system.nodes[0]); ASSERT_TRUE (node1->network.empty ()); - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); system.nodes.push_back (node2); auto endpoint = node1->network.endpoint (); @@ -3217,7 +3212,7 @@ TEST (node, peer_cache_restart) nano::endpoint_key endpoint_key{ endpoint.address ().to_v6 ().to_bytes (), endpoint.port () }; auto path (nano::unique_path ()); { - auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), path, system.logging, system.work)); + auto node2 (std::make_shared (system.io_ctx, system.get_available_port (), path, system.work)); system.nodes.push_back (node2); auto & store = node2->store; { @@ -3237,7 +3232,7 @@ TEST (node, peer_cache_restart) { nano::node_flags node_flags; node_flags.read_only = true; - auto node3 (std::make_shared (system.io_ctx, system.get_available_port (), path, system.logging, system.work, node_flags)); + auto node3 (std::make_shared (system.io_ctx, system.get_available_port (), path, system.work, node_flags)); system.nodes.push_back (node3); // Check cached peers after restart node3->network.start (); @@ -3342,7 +3337,7 @@ TEST (node, bidirectional_tcp) node_flags.disable_legacy_bootstrap = true; node_flags.disable_lazy_bootstrap = true; node_flags.disable_wallet_bootstrap = true; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node1 = system.add_node (node_config, node_flags); node_config.peering_port = system.get_available_port (); @@ -3540,7 +3535,7 @@ TEST (node, rollback_vote_self) TEST (node, rollback_gap_source) { nano::test::system system; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node = *system.add_node (node_config); nano::state_block_builder builder; @@ -3608,7 +3603,7 @@ TEST (node, rollback_gap_source) TEST (node, dependency_graph) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node = *system.add_node (config); @@ -3806,7 +3801,7 @@ TEST (node, dependency_graph) TEST (node, dependency_graph_frontier) { nano::test::system system; - nano::node_config config (system.get_available_port (), system.logging); + nano::node_config config (system.get_available_port ()); config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (config); config.peering_port = system.get_available_port (); @@ -3973,9 +3968,9 @@ namespace nano TEST (node, deferred_dependent_elections) { nano::test::system system; - nano::node_config node_config_1{ system.get_available_port (), system.logging }; + nano::node_config node_config_1{ system.get_available_port () }; node_config_1.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; - nano::node_config node_config_2{ system.get_available_port (), system.logging }; + nano::node_config node_config_2{ system.get_available_port () }; node_config_2.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; nano::node_flags flags; flags.disable_request_loop = true; @@ -4134,7 +4129,7 @@ TEST (node, pruning_automatic) { nano::test::system system{}; - nano::node_config node_config{ system.get_available_port (), system.logging }; + nano::node_config node_config{ system.get_available_port () }; // TODO: remove after allowing pruned voting node_config.enable_voting = false; node_config.max_pruning_age = std::chrono::seconds (1); @@ -4189,7 +4184,7 @@ TEST (node, pruning_age) { nano::test::system system{}; - nano::node_config node_config{ system.get_available_port (), system.logging }; + nano::node_config node_config{ system.get_available_port () }; // TODO: remove after allowing pruned voting node_config.enable_voting = false; @@ -4252,7 +4247,7 @@ TEST (node, pruning_depth) { nano::test::system system{}; - nano::node_config node_config{ system.get_available_port (), system.logging }; + nano::node_config node_config{ system.get_available_port () }; // TODO: remove after allowing pruned voting node_config.enable_voting = false; diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index 744e70acd8..84f659e880 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -196,35 +196,6 @@ TEST (toml, daemon_config_deserialize_defaults) ASSERT_EQ (conf.node.backlog_scan_batch_size, defaults.node.backlog_scan_batch_size); ASSERT_EQ (conf.node.backlog_scan_frequency, defaults.node.backlog_scan_frequency); - ASSERT_EQ (conf.node.logging.bulk_pull_logging_value, defaults.node.logging.bulk_pull_logging_value); - ASSERT_EQ (conf.node.logging.flush, defaults.node.logging.flush); - ASSERT_EQ (conf.node.logging.insufficient_work_logging_value, defaults.node.logging.insufficient_work_logging_value); - ASSERT_EQ (conf.node.logging.ledger_logging_value, defaults.node.logging.ledger_logging_value); - ASSERT_EQ (conf.node.logging.ledger_duplicate_logging_value, defaults.node.logging.ledger_duplicate_logging_value); - ASSERT_EQ (conf.node.logging.log_ipc_value, defaults.node.logging.log_ipc_value); - ASSERT_EQ (conf.node.logging.log_to_cerr_value, defaults.node.logging.log_to_cerr_value); - ASSERT_EQ (conf.node.logging.max_size, defaults.node.logging.max_size); - ASSERT_EQ (conf.node.logging.min_time_between_log_output.count (), defaults.node.logging.min_time_between_log_output.count ()); - ASSERT_EQ (conf.node.logging.network_logging_value, defaults.node.logging.network_logging_value); - ASSERT_EQ (conf.node.logging.network_keepalive_logging_value, defaults.node.logging.network_keepalive_logging_value); - ASSERT_EQ (conf.node.logging.network_message_logging_value, defaults.node.logging.network_message_logging_value); - ASSERT_EQ (conf.node.logging.network_node_id_handshake_logging_value, defaults.node.logging.network_node_id_handshake_logging_value); - ASSERT_EQ (conf.node.logging.network_packet_logging_value, defaults.node.logging.network_packet_logging_value); - ASSERT_EQ (conf.node.logging.network_publish_logging_value, defaults.node.logging.network_publish_logging_value); - ASSERT_EQ (conf.node.logging.network_timeout_logging_value, defaults.node.logging.network_timeout_logging_value); - ASSERT_EQ (conf.node.logging.node_lifetime_tracing_value, defaults.node.logging.node_lifetime_tracing_value); - ASSERT_EQ (conf.node.logging.network_telemetry_logging_value, defaults.node.logging.network_telemetry_logging_value); - ASSERT_EQ (conf.node.logging.network_rejected_logging_value, defaults.node.logging.network_rejected_logging_value); - ASSERT_EQ (conf.node.logging.rotation_size, defaults.node.logging.rotation_size); - ASSERT_EQ (conf.node.logging.single_line_record_value, defaults.node.logging.single_line_record_value); - ASSERT_EQ (conf.node.logging.stable_log_filename, defaults.node.logging.stable_log_filename); - ASSERT_EQ (conf.node.logging.timing_logging_value, defaults.node.logging.timing_logging_value); - ASSERT_EQ (conf.node.logging.active_update_value, defaults.node.logging.active_update_value); - ASSERT_EQ (conf.node.logging.upnp_details_logging_value, defaults.node.logging.upnp_details_logging_value); - ASSERT_EQ (conf.node.logging.vote_logging_value, defaults.node.logging.vote_logging_value); - ASSERT_EQ (conf.node.logging.rep_crawler_logging_value, defaults.node.logging.rep_crawler_logging_value); - ASSERT_EQ (conf.node.logging.work_generation_time_value, defaults.node.logging.work_generation_time_value); - ASSERT_EQ (conf.node.websocket_config.enabled, defaults.node.websocket_config.enabled); ASSERT_EQ (conf.node.websocket_config.address, defaults.node.websocket_config.address); ASSERT_EQ (conf.node.websocket_config.port, defaults.node.websocket_config.port); @@ -642,35 +613,6 @@ TEST (toml, daemon_config_deserialize_no_defaults) ASSERT_NE (conf.node.backlog_scan_batch_size, defaults.node.backlog_scan_batch_size); ASSERT_NE (conf.node.backlog_scan_frequency, defaults.node.backlog_scan_frequency); - ASSERT_NE (conf.node.logging.bulk_pull_logging_value, defaults.node.logging.bulk_pull_logging_value); - ASSERT_NE (conf.node.logging.flush, defaults.node.logging.flush); - ASSERT_NE (conf.node.logging.insufficient_work_logging_value, defaults.node.logging.insufficient_work_logging_value); - ASSERT_NE (conf.node.logging.ledger_logging_value, defaults.node.logging.ledger_logging_value); - ASSERT_NE (conf.node.logging.ledger_duplicate_logging_value, defaults.node.logging.ledger_duplicate_logging_value); - ASSERT_NE (conf.node.logging.log_ipc_value, defaults.node.logging.log_ipc_value); - ASSERT_NE (conf.node.logging.log_to_cerr_value, defaults.node.logging.log_to_cerr_value); - ASSERT_NE (conf.node.logging.max_size, defaults.node.logging.max_size); - ASSERT_NE (conf.node.logging.min_time_between_log_output.count (), defaults.node.logging.min_time_between_log_output.count ()); - ASSERT_NE (conf.node.logging.network_logging_value, defaults.node.logging.network_logging_value); - ASSERT_NE (conf.node.logging.network_keepalive_logging_value, defaults.node.logging.network_keepalive_logging_value); - ASSERT_NE (conf.node.logging.network_message_logging_value, defaults.node.logging.network_message_logging_value); - ASSERT_NE (conf.node.logging.network_node_id_handshake_logging_value, defaults.node.logging.network_node_id_handshake_logging_value); - ASSERT_NE (conf.node.logging.network_telemetry_logging_value, defaults.node.logging.network_telemetry_logging_value); - ASSERT_NE (conf.node.logging.network_rejected_logging_value, defaults.node.logging.network_rejected_logging_value); - ASSERT_NE (conf.node.logging.network_packet_logging_value, defaults.node.logging.network_packet_logging_value); - ASSERT_NE (conf.node.logging.network_publish_logging_value, defaults.node.logging.network_publish_logging_value); - ASSERT_NE (conf.node.logging.network_timeout_logging_value, defaults.node.logging.network_timeout_logging_value); - ASSERT_NE (conf.node.logging.node_lifetime_tracing_value, defaults.node.logging.node_lifetime_tracing_value); - ASSERT_NE (conf.node.logging.rotation_size, defaults.node.logging.rotation_size); - ASSERT_NE (conf.node.logging.single_line_record_value, defaults.node.logging.single_line_record_value); - ASSERT_NE (conf.node.logging.stable_log_filename, defaults.node.logging.stable_log_filename); - ASSERT_NE (conf.node.logging.timing_logging_value, defaults.node.logging.timing_logging_value); - ASSERT_NE (conf.node.logging.active_update_value, defaults.node.logging.active_update_value); - ASSERT_NE (conf.node.logging.upnp_details_logging_value, defaults.node.logging.upnp_details_logging_value); - ASSERT_NE (conf.node.logging.vote_logging_value, defaults.node.logging.vote_logging_value); - ASSERT_NE (conf.node.logging.rep_crawler_logging_value, defaults.node.logging.rep_crawler_logging_value); - ASSERT_NE (conf.node.logging.work_generation_time_value, defaults.node.logging.work_generation_time_value); - ASSERT_NE (conf.node.websocket_config.enabled, defaults.node.websocket_config.enabled); ASSERT_NE (conf.node.websocket_config.address, defaults.node.websocket_config.address); ASSERT_NE (conf.node.websocket_config.port, defaults.node.websocket_config.port); diff --git a/nano/core_test/unchecked_map.cpp b/nano/core_test/unchecked_map.cpp index b2012c4f5c..6b42cd8708 100644 --- a/nano/core_test/unchecked_map.cpp +++ b/nano/core_test/unchecked_map.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/nano/core_test/work_pool.cpp b/nano/core_test/work_pool.cpp index 44e726a8b9..1c429ca3a9 100644 --- a/nano/core_test/work_pool.cpp +++ b/nano/core_test/work_pool.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -90,8 +89,6 @@ TEST (work, cancel_many) TEST (work, opencl) { - nano::logging logging; - logging.init (nano::unique_path ()); nano::nlogger logger; bool error (false); nano::opencl_environment environment (error); diff --git a/nano/lib/CMakeLists.txt b/nano/lib/CMakeLists.txt index 0b68cfa29a..799f25aec6 100644 --- a/nano/lib/CMakeLists.txt +++ b/nano/lib/CMakeLists.txt @@ -50,7 +50,6 @@ add_library( lmdbconfig.cpp locks.hpp locks.cpp - logger_mt.hpp logging.hpp logging.cpp logging_enums.hpp @@ -121,8 +120,6 @@ target_link_libraries( Boost::asio Boost::circular_buffer Boost::dll - Boost::log_setup - Boost::log Boost::multiprecision Boost::program_options Boost::stacktrace) diff --git a/nano/lib/logger_mt.hpp b/nano/lib/logger_mt.hpp deleted file mode 100644 index 9afd47842a..0000000000 --- a/nano/lib/logger_mt.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace nano -{ -enum class severity_level -{ - normal = 0, - error -}; -} - -// Attribute value tag type -struct severity_tag; - -inline boost::log::formatting_ostream & operator<< (boost::log::formatting_ostream & strm, boost::log::to_log_manip const & manip) -{ - // Needs to match order in the severity_level enum - static std::array strings = { - "", - "Error: " - }; - - nano::severity_level level = manip.get (); - debug_assert (static_cast (level) < strings.size ()); - strm << strings[static_cast (level)]; - return strm; -} - -namespace nano -{ -// A wrapper around a boost logger object to allow minimum -// time spaced output to prevent logging happening too quickly. -class logger_mt -{ -private: - void add_to_stream (boost::log::record_ostream & stream) - { - } - - template - void add_to_stream (boost::log::record_ostream & stream, const LogItem & first_log_item, LogItems &&... remainder_log_items) - { - stream << first_log_item; - add_to_stream (stream, remainder_log_items...); - } - - template - void output (nano::severity_level severity_level, LogItems &&... log_items) - { - boost::log::record rec = boost_logger_mt.open_record (boost::log::keywords::severity = severity_level); - if (rec) - { - boost::log::record_ostream strm (rec); - add_to_stream (strm, std::forward (log_items)...); - strm.flush (); - boost_logger_mt.push_record (std::move (rec)); - } - } - -public: - logger_mt () = default; - - /** - * @param min_log_delta_a The minimum time between successive output - */ - explicit logger_mt (std::chrono::milliseconds const & min_log_delta_a) : - min_log_delta (min_log_delta_a) - { - } - - /* - * @param log_items A collection of objects with overloaded operator<< to be output to the log file - * @params severity_level The severity level that this log message should have. - */ - template - void always_log (nano::severity_level severity_level, LogItems &&... log_items) - { - output (severity_level, std::forward (log_items)...); - } - - /* - * @param log_items A collection of objects with overloaded operator<< to be output to the log file. - */ - template - void always_log (LogItems &&... log_items) - { - always_log (nano::severity_level::normal, std::forward (log_items)...); - } - - /* - * @param log_items Output to the log file if the last write was over min_log_delta time ago. - * @params severity_level The severity level that this log message should have. - * @return true if nothing was logged - */ - template - bool try_log (nano::severity_level severity_level, LogItems &&... log_items) - { - auto error (true); - auto time_now = std::chrono::steady_clock::now (); - nano::unique_lock lk (last_log_time_mutex); - if (((time_now - last_log_time) > min_log_delta) || last_log_time == std::chrono::steady_clock::time_point{}) - { - last_log_time = time_now; - lk.unlock (); - output (severity_level, std::forward (log_items)...); - error = false; - } - return error; - } - - /* - * @param log_items Output to the log file if the last write was over min_log_delta time ago. - * @return true if nothing was logged - */ - template - bool try_log (LogItems &&... log_items) - { - return try_log (nano::severity_level::normal, std::forward (log_items)...); - } - - std::chrono::milliseconds min_log_delta{ 0 }; - -private: - nano::mutex last_log_time_mutex; - std::chrono::steady_clock::time_point last_log_time; - boost::log::sources::severity_logger_mt boost_logger_mt; -}; -} diff --git a/nano/lib/logging.hpp b/nano/lib/logging.hpp index 2333894a4c..4d5fbb2483 100644 --- a/nano/lib/logging.hpp +++ b/nano/lib/logging.hpp @@ -65,4 +65,12 @@ class nlogger }; void initialize_logging (nano::log::preset = nano::log::preset::cli); +} + +namespace nano::logging +{ +inline void release_file_sink () +{ + // TODO +} } \ No newline at end of file diff --git a/nano/nano_node/daemon.cpp b/nano/nano_node/daemon.cpp index ccb62dac4e..277eb8726b 100644 --- a/nano/nano_node/daemon.cpp +++ b/nano/nano_node/daemon.cpp @@ -83,8 +83,6 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag } if (!error) { - config.node.logging.init (data_path); - auto tls_config (std::make_shared ()); error = nano::read_tls_config_toml (data_path, *tls_config, nlogger); if (error) diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 6b4b319064..cf0b369847 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -1124,10 +1124,8 @@ int main (int argc, char * const * argv) boost::asio::io_context io_ctx1; boost::asio::io_context io_ctx2; nano::work_pool work{ network_params.network, std::numeric_limits::max () }; - nano::logging logging; auto path1 (nano::unique_path ()); auto path2 (nano::unique_path ()); - logging.init (path1); std::vector config_overrides; auto config (vm.find ("config")); if (config != vm.end ()) @@ -1882,13 +1880,6 @@ int main (int argc, char * const * argv) } else if (vm.count ("debug_sys_logging")) { -#ifdef BOOST_WINDOWS - if (!nano::event_log_reg_entry_exists () && !nano::is_windows_elevated ()) - { - std::cerr << "The event log requires the HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Nano\\Nano registry entry, run again as administator to create it.\n"; - return 1; - } -#endif auto inactive_node = nano::default_inactive_node (data_path, vm); inactive_node->node->nlogger.critical ({}, "Testing system logger (CRITICAL)"); inactive_node->node->nlogger.error ({}, "Testing system logger (ERROR)"); diff --git a/nano/nano_rpc/entry.cpp b/nano/nano_rpc/entry.cpp index 51f78763e0..fd310d7d63 100644 --- a/nano/nano_rpc/entry.cpp +++ b/nano/nano_rpc/entry.cpp @@ -12,29 +12,13 @@ #include #include -#include -#include +#include #include namespace { nano::nlogger nlogger; -void logging_init (std::filesystem::path const & application_path_a) -{ - static std::atomic_flag logging_already_added = ATOMIC_FLAG_INIT; - if (!logging_already_added.test_and_set ()) - { - boost::log::add_common_attributes (); - auto path = application_path_a / "log"; - - uintmax_t max_size{ 128 * 1024 * 1024 }; - uintmax_t rotation_size{ 4 * 1024 * 1024 }; - bool flush{ true }; - boost::log::add_file_log (boost::log::keywords::target = path, boost::log::keywords::file_name = path / "rpc_log_%Y-%m-%d_%H-%M-%S.%N.log", boost::log::keywords::rotation_size = rotation_size, boost::log::keywords::auto_flush = flush, boost::log::keywords::scan_method = boost::log::sinks::file::scan_method::scan_matching, boost::log::keywords::max_size = max_size, boost::log::keywords::format = "[%TimeStamp%]: %Message%"); - } -} - volatile sig_atomic_t sig_int_or_term = 0; void run (std::filesystem::path const & data_path, std::vector const & config_overrides) @@ -53,8 +37,6 @@ void run (std::filesystem::path const & data_path, std::vector cons auto error = nano::read_rpc_config_toml (data_path, rpc_config, config_overrides); if (!error) { - logging_init (data_path); - auto tls_config (std::make_shared ()); error = nano::read_tls_config_toml (data_path, *tls_config, nlogger); if (error) diff --git a/nano/nano_wallet/entry.cpp b/nano/nano_wallet/entry.cpp index 2ab7fbc7d2..e767ef4fd1 100644 --- a/nano/nano_wallet/entry.cpp +++ b/nano/nano_wallet/entry.cpp @@ -108,8 +108,6 @@ int run_wallet (QApplication & application, int argc, char * const * argv, std:: { nano::set_use_memory_pools (config.node.use_memory_pools); - config.node.logging.init (data_path); - auto tls_config (std::make_shared ()); error = nano::read_tls_config_toml (data_path, *tls_config, nlogger); if (error) diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index 3846c78973..1f893a7cdb 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -112,8 +112,6 @@ add_library( json_handler.cpp ledger_walker.hpp ledger_walker.cpp - logging.hpp - logging.cpp make_store.hpp make_store.cpp network.hpp @@ -210,8 +208,6 @@ target_link_libraries( argon2 lmdb Boost::beast - Boost::log_setup - Boost::log Boost::program_options Boost::stacktrace Boost::system diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 7b455fb76c..f5667628ff 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -174,7 +174,7 @@ bool nano::block_processor::should_log () auto now (std::chrono::steady_clock::now ()); if (next_log < now) { - next_log = now + (node.config.logging.timing_logging () ? std::chrono::seconds (2) : std::chrono::seconds (15)); + next_log = now + std::chrono::seconds (15); result = true; } return result; diff --git a/nano/node/bootstrap/bootstrap_connections.cpp b/nano/node/bootstrap/bootstrap_connections.cpp index 372142d44e..a11b828c5c 100644 --- a/nano/node/bootstrap/bootstrap_connections.cpp +++ b/nano/node/bootstrap/bootstrap_connections.cpp @@ -165,20 +165,17 @@ void nano::bootstrap_connections::connect_client (nano::tcp_endpoint const & end } else { - if (this_l->node.config.logging.network_logging ()) + switch (ec.value ()) { - switch (ec.value ()) - { - default: - this_l->node.nlogger.debug (nano::log::type::bootstrap, "Error initiating bootstrap connection to: {} ({})", nano::util::to_str (endpoint_a), ec.message ()); - break; - case boost::system::errc::connection_refused: - case boost::system::errc::operation_canceled: - case boost::system::errc::timed_out: - case 995: // Windows The I/O operation has been aborted because of either a thread exit or an application request - case 10061: // Windows No connection could be made because the target machine actively refused it - break; - } + default: + this_l->node.nlogger.debug (nano::log::type::bootstrap, "Error initiating bootstrap connection to: {} ({})", nano::util::to_str (endpoint_a), ec.message ()); + break; + case boost::system::errc::connection_refused: + case boost::system::errc::operation_canceled: + case boost::system::errc::timed_out: + case 995: // Windows The I/O operation has been aborted because of either a thread exit or an application request + case 10061: // Windows No connection could be made because the target machine actively refused it + break; } } --this_l->connections_count; diff --git a/nano/node/confirmation_height_bounded.cpp b/nano/node/confirmation_height_bounded.cpp index 44569ebbe4..8bcb25756a 100644 --- a/nano/node/confirmation_height_bounded.cpp +++ b/nano/node/confirmation_height_bounded.cpp @@ -1,7 +1,5 @@ -#include #include #include -#include #include #include #include diff --git a/nano/node/confirmation_height_bounded.hpp b/nano/node/confirmation_height_bounded.hpp index c42cd61397..ee453769cd 100644 --- a/nano/node/confirmation_height_bounded.hpp +++ b/nano/node/confirmation_height_bounded.hpp @@ -12,8 +12,6 @@ namespace nano { class ledger; -class logging; -class logger_mt; class write_database_queue; class write_guard; diff --git a/nano/node/confirmation_height_processor.cpp b/nano/node/confirmation_height_processor.cpp index 6e937c54c1..a3c9b325c7 100644 --- a/nano/node/confirmation_height_processor.cpp +++ b/nano/node/confirmation_height_processor.cpp @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/nano/node/confirmation_height_unbounded.cpp b/nano/node/confirmation_height_unbounded.cpp index c7edd9cdbc..4b7f9fffe5 100644 --- a/nano/node/confirmation_height_unbounded.cpp +++ b/nano/node/confirmation_height_unbounded.cpp @@ -1,7 +1,5 @@ -#include #include #include -#include #include #include #include diff --git a/nano/node/confirmation_height_unbounded.hpp b/nano/node/confirmation_height_unbounded.hpp index 9bee338c4d..2264d6fa06 100644 --- a/nano/node/confirmation_height_unbounded.hpp +++ b/nano/node/confirmation_height_unbounded.hpp @@ -13,8 +13,6 @@ namespace nano { class ledger; -class logging; -class logger_mt; class write_database_queue; class write_guard; diff --git a/nano/node/ipc/ipc_server.cpp b/nano/node/ipc/ipc_server.cpp index 2a3e4a0185..b629fc72e2 100644 --- a/nano/node/ipc/ipc_server.cpp +++ b/nano/node/ipc/ipc_server.cpp @@ -23,8 +23,6 @@ #include -using namespace boost::log; - namespace { /** diff --git a/nano/node/logging.cpp b/nano/node/logging.cpp deleted file mode 100644 index 5dcfb9f816..0000000000 --- a/nano/node/logging.cpp +++ /dev/null @@ -1,344 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_WINDOWS -#else -#define BOOST_LOG_USE_NATIVE_SYSLOG -#include -#endif - -BOOST_LOG_ATTRIBUTE_KEYWORD (severity, "Severity", nano::severity_level) - -boost::shared_ptr> nano::logging::file_sink; -std::atomic_flag nano::logging::logging_already_added ATOMIC_FLAG_INIT; - -void nano::logging::init (std::filesystem::path const & application_path_a) -{ - if (!logging_already_added.test_and_set ()) - { - boost::log::add_common_attributes (); - auto format = boost::log::expressions::stream << boost::log::expressions::attr ("Severity") << boost::log::expressions::smessage; - auto format_with_timestamp = boost::log::expressions::stream << "[" << boost::log::expressions::attr ("TimeStamp") << "]: " << boost::log::expressions::attr ("Severity") << boost::log::expressions::smessage; - - if (log_to_cerr ()) - { - boost::log::add_console_log (std::cerr, boost::log::keywords::format = format_with_timestamp); - } - -#ifdef BOOST_WINDOWS -#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 - if (stable_log_filename) - { - stable_log_filename = false; - std::cerr << "The stable_log_filename config setting is only available when building with Boost 1.70 or later. Reverting to old behavior." << std::endl; - } -#endif - - auto path = application_path_a / "log"; - if (stable_log_filename) - { -#if BOOST_VERSION >= 107000 - auto const file_name = path / "node.log"; - // Logging to node.log and node_ instead of log_.log is deliberate. This way, - // existing log monitoring scripts expecting the old logfile structure will fail immediately instead - // of reading only rotated files with old entries. - file_sink = boost::log::add_file_log (boost::log::keywords::target = path, - boost::log::keywords::file_name = file_name, - boost::log::keywords::target_file_name = path / "node_%Y-%m-%d_%H-%M-%S.%N.log", - boost::log::keywords::open_mode = std::ios_base::out | std::ios_base::app, // append to node.log if it exists - boost::log::keywords::enable_final_rotation = false, // for stable log filenames, don't rotate on destruction - boost::log::keywords::rotation_size = rotation_size, // max file size in bytes before rotation - boost::log::keywords::auto_flush = flush, - boost::log::keywords::scan_method = boost::log::sinks::file::scan_method::scan_matching, - boost::log::keywords::max_size = max_size, // max total size in bytes of all log files - boost::log::keywords::format = format_with_timestamp); - - if (!std::filesystem::exists (file_name)) - { - // Create temp stream to first create the file - std::ofstream stream (file_name.string ()); - } - - // Set permissions before opening otherwise Windows only has read permissions - nano::set_secure_perm_file (file_name); - -#else - debug_assert (false); -#endif - } - else - { - file_sink = boost::log::add_file_log (boost::log::keywords::target = path, - boost::log::keywords::file_name = path / "log_%Y-%m-%d_%H-%M-%S.%N.log", - boost::log::keywords::rotation_size = rotation_size, - boost::log::keywords::auto_flush = flush, - boost::log::keywords::scan_method = boost::log::sinks::file::scan_method::scan_matching, - boost::log::keywords::max_size = max_size, - boost::log::keywords::format = format_with_timestamp); - } - - struct exception_handler - { - void operator() (std::exception const & e) const - { - std::cerr << "Logging exception: " << e.what () << std::endl; - } - }; - - boost::log::core::get ()->set_exception_handler (boost::log::make_exception_handler (exception_handler ())); - } - //clang-format on -} - -void nano::logging::release_file_sink () -{ - if (logging_already_added.test_and_set ()) - { - boost::log::core::get ()->remove_sink (nano::logging::file_sink); - nano::logging::file_sink.reset (); - logging_already_added.clear (); - } -} - -nano::error nano::logging::serialize_toml (nano::tomlconfig & toml) const -{ - toml.put ("ledger", ledger_logging_value, "Log ledger related messages.\ntype:bool"); - toml.put ("ledger_duplicate", ledger_duplicate_logging_value, "Log when a duplicate block is attempted inserted into the ledger.\ntype:bool"); - toml.put ("ledger_rollback", election_fork_tally_logging_value, "Log when a block is replaced in the ledger.\ntype:bool"); - toml.put ("vote", vote_logging_value, "Vote logging. Enabling this option leads to a high volume.\nof log messages which may affect node performance.\ntype:bool"); - toml.put ("rep_crawler", rep_crawler_logging_value, "Rep crawler logging. Enabling this option leads to a high volume.\nof log messages which may affect node performance.\ntype:bool"); - toml.put ("election_expiration", election_expiration_tally_logging_value, "Log election tally on expiration.\ntype:bool"); - toml.put ("election_fork", election_fork_tally_logging_value, "Log election tally when more than one block is seen.\ntype:bool"); - toml.put ("network", network_logging_value, "Log network related messages.\ntype:bool"); - toml.put ("network_timeout", network_timeout_logging_value, "Log TCP timeouts.\ntype:bool"); - toml.put ("network_message", network_message_logging_value, "Log network errors and message details.\ntype:bool"); - toml.put ("network_publish", network_publish_logging_value, "Log publish related network messages.\ntype:bool"); - toml.put ("network_packet", network_packet_logging_value, "Log network packet activity.\ntype:bool"); - toml.put ("network_keepalive", network_keepalive_logging_value, "Log keepalive related messages.\ntype:bool"); - toml.put ("network_node_id_handshake", network_node_id_handshake_logging_value, "Log node-id handshake related messages.\ntype:bool"); - toml.put ("network_telemetry", network_telemetry_logging_value, "Log telemetry related messages.\ntype:bool"); - toml.put ("network_rejected", network_rejected_logging_value, "Log message when a connection is rejected.\ntype:bool"); - toml.put ("node_lifetime_tracing", node_lifetime_tracing_value, "Log node startup and shutdown messages.\ntype:bool"); - toml.put ("insufficient_work", insufficient_work_logging_value, "Log if insufficient work is detected.\ntype:bool"); - toml.put ("log_ipc", log_ipc_value, "Log IPC related activity.\ntype:bool"); - toml.put ("bulk_pull", bulk_pull_logging_value, "Log bulk pull errors and messages.\ntype:bool"); - toml.put ("work_generation_time", work_generation_time_value, "Log work generation timing information.\ntype:bool"); - toml.put ("upnp_details", upnp_details_logging_value, "Log UPNP discovery details..\nWarning: this may include information.\nabout discovered devices, such as product identification. Please review before sharing logs.\ntype:bool"); - toml.put ("timing", timing_logging_value, "Log detailed timing information for various node operations.\ntype:bool"); - toml.put ("active_update", active_update_value, "Log when a block is updated while in active transactions.\ntype:bool"); - toml.put ("election_result", election_result_logging_value, "Log election result when cleaning up election from active election container.\ntype:bool"); - toml.put ("log_to_cerr", log_to_cerr_value, "Log to standard error in addition to the log file. Not recommended for production systems.\ntype:bool"); - toml.put ("max_size", max_size, "Maximum log file size in bytes.\ntype:uint64"); - toml.put ("rotation_size", rotation_size, "Log file rotation size in character count.\ntype:uint64"); - toml.put ("flush", flush, "If enabled, immediately flush new entries to log file.\nWarning: this may negatively affect logging performance.\ntype:bool"); - toml.put ("min_time_between_output", min_time_between_log_output.count (), "Minimum time that must pass for low priority entries to be logged.\nWarning: decreasing this value may result in a very large amount of logs.\ntype:milliseconds"); - toml.put ("single_line_record", single_line_record_value, "Keep log entries on single lines.\ntype:bool"); - toml.put ("stable_log_filename", stable_log_filename, "Append to log/node.log without a timestamp in the filename.\nThe file is not emptied on startup if it exists, but appended to.\ntype:bool"); - - return toml.get_error (); -} - -nano::error nano::logging::deserialize_toml (nano::tomlconfig & toml) -{ - toml.get ("ledger", ledger_logging_value); - toml.get ("ledger_duplicate", ledger_duplicate_logging_value); - toml.get ("ledger_rollback", ledger_rollback_logging_value); - toml.get ("vote", vote_logging_value); - toml.get ("rep_crawler", rep_crawler_logging_value); - toml.get ("election_expiration", election_expiration_tally_logging_value); - toml.get ("election_fork", election_fork_tally_logging_value); - toml.get ("network", network_logging_value); - toml.get ("network_timeout", network_timeout_logging_value); - toml.get ("network_message", network_message_logging_value); - toml.get ("network_publish", network_publish_logging_value); - toml.get ("network_packet", network_packet_logging_value); - toml.get ("network_keepalive", network_keepalive_logging_value); - toml.get ("network_node_id_handshake", network_node_id_handshake_logging_value); - toml.get ("network_telemetry_logging", network_telemetry_logging_value); - toml.get ("network_rejected_logging", network_rejected_logging_value); - toml.get ("node_lifetime_tracing", node_lifetime_tracing_value); - toml.get ("insufficient_work", insufficient_work_logging_value); - toml.get ("log_ipc", log_ipc_value); - toml.get ("bulk_pull", bulk_pull_logging_value); - toml.get ("work_generation_time", work_generation_time_value); - toml.get ("upnp_details", upnp_details_logging_value); - toml.get ("timing", timing_logging_value); - toml.get ("active_update", active_update_value); - toml.get ("election_result", election_result_logging_value); - toml.get ("log_to_cerr", log_to_cerr_value); - toml.get ("flush", flush); - toml.get ("single_line_record", single_line_record_value); - toml.get ("max_size", max_size); - toml.get ("rotation_size", rotation_size); - auto min_time_between_log_output_l = min_time_between_log_output.count (); - toml.get ("min_time_between_output", min_time_between_log_output_l); - min_time_between_log_output = std::chrono::milliseconds (min_time_between_log_output_l); - toml.get ("stable_log_filename", stable_log_filename); - - return toml.get_error (); -} - -bool nano::logging::ledger_logging () const -{ - return ledger_logging_value; -} - -bool nano::logging::ledger_duplicate_logging () const -{ - return ledger_logging () && ledger_duplicate_logging_value; -} - -bool nano::logging::ledger_rollback_logging () const -{ - return ledger_rollback_logging_value; -} - -bool nano::logging::vote_logging () const -{ - return vote_logging_value; -} - -bool nano::logging::rep_crawler_logging () const -{ - return rep_crawler_logging_value; -} - -bool nano::logging::election_expiration_tally_logging () const -{ - return election_expiration_tally_logging_value; -} - -bool nano::logging::election_fork_tally_logging () const -{ - return election_fork_tally_logging_value; -} - -bool nano::logging::network_logging () const -{ - return network_logging_value; -} - -bool nano::logging::network_timeout_logging () const -{ - return network_logging () && network_timeout_logging_value; -} - -bool nano::logging::network_message_logging () const -{ - return network_logging () && network_message_logging_value; -} - -bool nano::logging::network_publish_logging () const -{ - return network_logging () && network_publish_logging_value; -} - -bool nano::logging::network_packet_logging () const -{ - return network_logging () && network_packet_logging_value; -} - -bool nano::logging::network_keepalive_logging () const -{ - return network_logging () && network_keepalive_logging_value; -} - -bool nano::logging::network_node_id_handshake_logging () const -{ - return network_logging () && network_node_id_handshake_logging_value; -} - -bool nano::logging::network_telemetry_logging () const -{ - return network_logging () && network_telemetry_logging_value; -} - -bool nano::logging::network_rejected_logging () const -{ - return network_logging () && network_rejected_logging_value; -} - -bool nano::logging::node_lifetime_tracing () const -{ - return node_lifetime_tracing_value; -} - -bool nano::logging::insufficient_work_logging () const -{ - return network_logging () && insufficient_work_logging_value; -} - -bool nano::logging::log_ipc () const -{ - return network_logging () && log_ipc_value; -} - -bool nano::logging::bulk_pull_logging () const -{ - return network_logging () && bulk_pull_logging_value; -} - -bool nano::logging::callback_logging () const -{ - return network_logging (); -} - -bool nano::logging::work_generation_time () const -{ - return work_generation_time_value; -} - -bool nano::logging::upnp_details_logging () const -{ - return upnp_details_logging_value; -} - -bool nano::logging::timing_logging () const -{ - return timing_logging_value; -} - -bool nano::logging::active_update_logging () const -{ - return active_update_value; -} - -bool nano::logging::election_result_logging () const -{ - return election_result_logging_value; -} - -bool nano::logging::log_to_cerr () const -{ - return log_to_cerr_value; -} - -bool nano::logging::single_line_record () const -{ - return single_line_record_value; -} diff --git a/nano/node/logging.hpp b/nano/node/logging.hpp deleted file mode 100644 index e8f206a51e..0000000000 --- a/nano/node/logging.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include -#include -#include - -#define FATAL_LOG_PREFIX "FATAL ERROR: " - -namespace boost -{ -BOOST_LOG_OPEN_NAMESPACE -namespace sinks -{ - class text_file_backend; - - template - class synchronous_sink; -} - -BOOST_LOG_CLOSE_NAMESPACE - -} - -namespace nano -{ -class tomlconfig; -class logging final -{ -public: - nano::error serialize_toml (nano::tomlconfig &) const; - nano::error deserialize_toml (nano::tomlconfig &); - bool ledger_logging () const; - bool ledger_duplicate_logging () const; - bool ledger_rollback_logging () const; - bool vote_logging () const; - bool rep_crawler_logging () const; - bool election_fork_tally_logging () const; - bool election_expiration_tally_logging () const; - bool network_logging () const; - bool network_timeout_logging () const; - bool network_message_logging () const; - bool network_publish_logging () const; - bool network_packet_logging () const; - bool network_keepalive_logging () const; - bool network_node_id_handshake_logging () const; - bool network_telemetry_logging () const; - bool network_rejected_logging () const; - bool node_lifetime_tracing () const; - bool insufficient_work_logging () const; - bool upnp_details_logging () const; - bool timing_logging () const; - bool log_ipc () const; - bool bulk_pull_logging () const; - bool callback_logging () const; - bool work_generation_time () const; - bool active_update_logging () const; - bool election_result_logging () const; - bool log_to_cerr () const; - bool single_line_record () const; - void init (std::filesystem::path const &); - - bool ledger_logging_value{ false }; - bool ledger_duplicate_logging_value{ false }; - bool ledger_rollback_logging_value{ false }; - bool vote_logging_value{ false }; - bool rep_crawler_logging_value{ false }; - bool election_fork_tally_logging_value{ false }; - bool election_expiration_tally_logging_value{ false }; - bool network_logging_value{ true }; - bool network_timeout_logging_value{ false }; - bool network_message_logging_value{ false }; - bool network_publish_logging_value{ false }; - bool network_packet_logging_value{ false }; - bool network_keepalive_logging_value{ false }; - bool network_node_id_handshake_logging_value{ false }; - bool network_telemetry_logging_value{ false }; - bool network_rejected_logging_value{ false }; - bool node_lifetime_tracing_value{ false }; - bool insufficient_work_logging_value{ true }; - bool log_ipc_value{ true }; - bool bulk_pull_logging_value{ false }; - bool work_generation_time_value{ true }; - bool upnp_details_logging_value{ false }; - bool timing_logging_value{ false }; - bool active_update_value{ false }; - bool election_result_logging_value{ false }; - bool log_to_cerr_value{ false }; - bool flush{ true }; - uintmax_t max_size{ 128 * 1024 * 1024 }; - uintmax_t rotation_size{ 4 * 1024 * 1024 }; - bool stable_log_filename{ false }; - std::chrono::milliseconds min_time_between_log_output{ 5 }; - bool single_line_record_value{ false }; - static void release_file_sink (); - -private: - static boost::shared_ptr> file_sink; - static std::atomic_flag logging_already_added; -}; -} diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 8bd9c40df4..9908c22d9b 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -133,8 +133,8 @@ nano::keypair nano::load_or_create_node_id (std::filesystem::path const & applic } } -nano::node::node (boost::asio::io_context & io_ctx_a, uint16_t peering_port_a, std::filesystem::path const & application_path_a, nano::logging const & logging_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) : - node (io_ctx_a, application_path_a, nano::node_config (peering_port_a, logging_a), work_a, flags_a, seq) +nano::node::node (boost::asio::io_context & io_ctx_a, uint16_t peering_port_a, std::filesystem::path const & application_path_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) : + node (io_ctx_a, application_path_a, nano::node_config (peering_port_a), work_a, flags_a, seq) { } @@ -150,7 +150,6 @@ nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path cons flags (flags_a), work (work_a), distributed_work (*this), - logger (config_a.logging.min_time_between_log_output), store_impl (nano::make_store (nlogger, application_path_a, network_params.ledger, flags.read_only, true, config_a.rocksdb_config, config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_config, config_a.backup_before_upgrade)), store (*store_impl), unchecked{ stats, flags.disable_block_processor_unchecked_deletion }, @@ -1508,8 +1507,6 @@ nano::node_wrapper::node_wrapper (std::filesystem::path const & path_a, std::fil auto & node_config = daemon_config.node; node_config.peering_port = 24000; - node_config.logging.max_size = std::numeric_limits::max (); - node_config.logging.init (path_a); node = std::make_shared (*io_context, path_a, node_config, work, node_flags_a); } diff --git a/nano/node/node.hpp b/nano/node/node.hpp index 435962312a..5e3fe7e037 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include @@ -74,7 +73,7 @@ class node final : public std::enable_shared_from_this nano::nlogger nlogger; public: - node (boost::asio::io_context &, uint16_t, std::filesystem::path const &, nano::logging const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0); + node (boost::asio::io_context &, uint16_t, std::filesystem::path const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0); node (boost::asio::io_context &, std::filesystem::path const &, nano::node_config const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0); ~node (); @@ -155,7 +154,6 @@ class node final : public std::enable_shared_from_this nano::node_flags flags; nano::work_pool & work; nano::distributed_work_factory distributed_work; - nano::logger_mt logger; std::unique_ptr store_impl; nano::store::component & store; nano::unchecked_map unchecked; diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index 2453c2c24d..61179c685c 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -21,15 +21,14 @@ std::string const default_test_peer_network = nano::get_env_or_default ("NANO_DE } nano::node_config::node_config (nano::network_params & network_params) : - node_config (std::nullopt, nano::logging (), network_params) + node_config (std::nullopt, network_params) { } -nano::node_config::node_config (const std::optional & peering_port_a, nano::logging const & logging_a, nano::network_params & network_params) : +nano::node_config::node_config (const std::optional & peering_port_a, nano::network_params & network_params) : network_params{ network_params }, peering_port{ peering_port_a }, hinted_scheduler{ network_params.network }, - logging{ logging_a }, websocket_config{ network_params.network }, ipc_config{ network_params.network }, external_address{ boost::asio::ip::address_v6{}.to_string () } @@ -168,10 +167,6 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const callback_l.put ("target", callback_target, "Callback target path.\ntype:string,uri"); toml.put_child ("httpcallback", callback_l); - nano::tomlconfig logging_l; - logging.serialize_toml (logging_l); - toml.put_child ("logging", logging_l); - nano::tomlconfig websocket_l; websocket_config.serialize_toml (websocket_l); toml.put_child ("websocket", websocket_l); @@ -223,12 +218,6 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) callback_l.get ("target", callback_target); } - if (toml.has_key ("logging")) - { - auto logging_l (toml.get_required_child ("logging")); - logging.deserialize_toml (logging_l); - } - if (toml.has_key ("websocket")) { auto websocket_config_l (toml.get_required_child ("websocket")); diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 0cc4116270..561a844dc0 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -39,7 +38,7 @@ class node_config { public: node_config (nano::network_params & network_params = nano::dev::network_params); - node_config (const std::optional &, nano::logging const &, nano::network_params & network_params = nano::dev::network_params); + node_config (const std::optional &, nano::network_params & network_params = nano::dev::network_params); nano::error serialize_toml (nano::tomlconfig &) const; nano::error deserialize_toml (nano::tomlconfig &); @@ -50,7 +49,6 @@ class node_config std::optional peering_port{}; nano::scheduler::optimistic_config optimistic_scheduler; nano::scheduler::hinted_config hinted_scheduler; - nano::logging logging; std::vector> work_peers; std::vector> secondary_work_peers{ { "127.0.0.1", 8076 } }; /* Default of nano-pow-server */ std::vector preconfigured_peers; diff --git a/nano/node/vote_processor.cpp b/nano/node/vote_processor.cpp index a13f660684..96887b39c8 100644 --- a/nano/node/vote_processor.cpp +++ b/nano/node/vote_processor.cpp @@ -1,4 +1,4 @@ -#include + #include #include #include @@ -63,7 +63,8 @@ void nano::vote_processor::process_loop () condition.notify_all (); log_this_iteration = false; - if (config.logging.network_logging () && votes_l.size () > 50) + // TODO: This is a temporary measure to prevent spamming the logs until we can implement a better solution + if (votes_l.size () > 1024 * 4) { /* * Only log the timing information for this iteration if diff --git a/nano/rpc/rpc_connection.cpp b/nano/rpc/rpc_connection.cpp index 4d0232bf63..f8c4b34b59 100644 --- a/nano/rpc/rpc_connection.cpp +++ b/nano/rpc/rpc_connection.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff --git a/nano/rpc/rpc_connection.hpp b/nano/rpc/rpc_connection.hpp index e0f18367ff..da37b47e6d 100644 --- a/nano/rpc/rpc_connection.hpp +++ b/nano/rpc/rpc_connection.hpp @@ -19,7 +19,6 @@ using socket_type = boost::asio::basic_stream_socket #include #include -#include #include #include #include diff --git a/nano/rpc/rpc_handler.hpp b/nano/rpc/rpc_handler.hpp index 92850497cc..b8fd6093ce 100644 --- a/nano/rpc/rpc_handler.hpp +++ b/nano/rpc/rpc_handler.hpp @@ -11,7 +11,6 @@ namespace nano { class rpc_config; class rpc_handler_interface; -class logger_mt; class rpc_handler_request_params; class rpc_handler : public std::enable_shared_from_this diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index f57569ac06..defd481229 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -1675,7 +1675,7 @@ TEST (rpc, keepalive) { nano::test::system system; auto node0 = add_ipc_enabled_node (system); - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); node1->start (); system.nodes.push_back (node1); auto const rpc_ctx = add_rpc (system, node0); @@ -5374,7 +5374,6 @@ TEST (rpc, block_confirm_confirmed) config.callback_address = "localhost"; config.callback_port = system.get_available_port (); config.callback_target = "/"; - config.logging.init (path); auto node = add_ipc_enabled_node (system, config); { auto transaction (node->store.tx_begin_read ()); diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index ef0b52a22b..2433dfe50b 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -91,7 +91,7 @@ TEST (system, receive_while_synchronizing) uint32_t count (1000); system.generate_mass_activity (count, *system.nodes[0]); nano::keypair key; - auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.logging, system.work)); + auto node1 (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); ASSERT_FALSE (node1->init_error ()); auto wallet (node1->wallets.create (1)); wallet->insert_adhoc (nano::dev::genesis_key.prv); // For voting @@ -2125,7 +2125,7 @@ TEST (node, wallet_create_block_confirm_conflicts) { nano::test::system system; nano::block_builder builder; - nano::node_config node_config (system.get_available_port (), system.logging); + nano::node_config node_config (system.get_available_port ()); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node = system.add_node (node_config); auto const num_blocks = 10000; diff --git a/nano/test_common/CMakeLists.txt b/nano/test_common/CMakeLists.txt index 337d34211d..6271377f45 100644 --- a/nano/test_common/CMakeLists.txt +++ b/nano/test_common/CMakeLists.txt @@ -15,7 +15,7 @@ add_library( testutil.hpp testutil.cpp) -target_link_libraries(test_common node gtest Boost::log_setup Boost::log) +target_link_libraries(test_common node gtest) include_directories(${CMAKE_SOURCE_DIR}/submodules) include_directories(${CMAKE_SOURCE_DIR}/submodules/gtest/googletest/include) diff --git a/nano/test_common/ledger.hpp b/nano/test_common/ledger.hpp index 7e86ea90f7..c17d8c9398 100644 --- a/nano/test_common/ledger.hpp +++ b/nano/test_common/ledger.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/nano/test_common/network.cpp b/nano/test_common/network.cpp index 3241afca61..1d584ac185 100644 --- a/nano/test_common/network.cpp +++ b/nano/test_common/network.cpp @@ -26,7 +26,7 @@ std::shared_ptr nano::test::establish_tcp (nano::t std::shared_ptr nano::test::add_outer_node (nano::test::system & system_a, nano::node_flags flags_a) { - auto outer_node = std::make_shared (system_a.io_ctx, system_a.get_available_port (), nano::unique_path (), system_a.logging, system_a.work, flags_a); + auto outer_node = std::make_shared (system_a.io_ctx, system_a.get_available_port (), nano::unique_path (), system_a.work, flags_a); outer_node->start (); system_a.nodes.push_back (outer_node); return outer_node; diff --git a/nano/test_common/system.cpp b/nano/test_common/system.cpp index cb0e1974cb..b8b9706e94 100644 --- a/nano/test_common/system.cpp +++ b/nano/test_common/system.cpp @@ -132,7 +132,6 @@ nano::test::system::system () { deadline_scaling_factor = std::stod (scale_str); } - logging.init (nano::unique_path ()); } nano::test::system::system (uint16_t count_a, nano::transport::transport_type type_a, nano::node_flags flags_a) : @@ -563,7 +562,7 @@ void nano::test::system::stop () nano::node_config nano::test::system::default_config () { - nano::node_config config{ get_available_port (), logging }; + nano::node_config config{ get_available_port () }; return config; } diff --git a/nano/test_common/system.hpp b/nano/test_common/system.hpp index f0f31afd92..278492edf4 100644 --- a/nano/test_common/system.hpp +++ b/nano/test_common/system.hpp @@ -66,7 +66,6 @@ namespace test public: boost::asio::io_context io_ctx; std::vector> nodes; - nano::logging logging; nano::stats stats; nano::nlogger nlogger; nano::work_pool work{ nano::dev::network_params.network, std::max (nano::hardware_concurrency (), 1u) }; diff --git a/nano/test_common/testutil.hpp b/nano/test_common/testutil.hpp index 6a5ab1e379..34459f457d 100644 --- a/nano/test_common/testutil.hpp +++ b/nano/test_common/testutil.hpp @@ -9,8 +9,6 @@ #include #include -#include -#include #include #include @@ -138,54 +136,6 @@ namespace test { class system; - class stringstream_mt_sink : public boost::iostreams::sink - { - public: - stringstream_mt_sink () = default; - stringstream_mt_sink (stringstream_mt_sink const & sink) - { - nano::lock_guard guard{ mutex }; - ss << sink.ss.str (); - } - - std::streamsize write (char const * string_to_write, std::streamsize size) - { - nano::lock_guard guard{ mutex }; - ss << std::string (string_to_write, size); - return size; - } - - std::string str () - { - nano::lock_guard guard{ mutex }; - return ss.str (); - } - - private: - mutable nano::mutex mutex; - std::stringstream ss; - }; - - class boost_log_cerr_redirect - { - public: - boost_log_cerr_redirect (std::streambuf * new_buffer) : - old (std::cerr.rdbuf (new_buffer)) - { - console_sink = (boost::log::add_console_log (std::cerr, boost::log::keywords::format = "%Message%")); - } - - ~boost_log_cerr_redirect () - { - std::cerr.rdbuf (old); - boost::log::core::get ()->remove_sink (console_sink); - } - - private: - std::streambuf * old; - boost::shared_ptr> console_sink; - }; - class cout_redirect { public: