Fixing issue where log rotation size couldn't be increased.
This commit is contained in:
parent
e3cec6c7ee
commit
f145844fff
7 changed files with 58 additions and 35 deletions
|
@ -19,7 +19,8 @@ TEST (node, block_store_path_failure)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging (path);
|
||||
rai::logging logging;
|
||||
logging.init (path);
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
auto node (std::make_shared <rai::node> (init, *service, 0, path, alarm, logging, work));
|
||||
ASSERT_TRUE (node->wallets.items.empty ());
|
||||
|
@ -32,7 +33,8 @@ TEST (node, inactive_supply)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::node_config config (path);
|
||||
rai::node_config config;
|
||||
config.logging.init (path);
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
config.inactive_supply = 10;
|
||||
auto node (std::make_shared <rai::node> (init, *service, path, alarm, config, work));
|
||||
|
@ -45,7 +47,8 @@ TEST (node, password_fanout)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::node_config config (path);
|
||||
rai::node_config config;
|
||||
config.logging.init (path);
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
config.password_fanout = 10;
|
||||
auto node (std::make_shared <rai::node> (init, *service, path, alarm, config, work));
|
||||
|
@ -401,7 +404,8 @@ TEST (node, working)
|
|||
TEST (logging, serialization)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
logging1.ledger_logging_value = !logging1.ledger_logging_value;
|
||||
logging1.ledger_duplicate_logging_value = !logging1.ledger_duplicate_logging_value;
|
||||
logging1.network_logging_value = !logging1.network_logging_value;
|
||||
|
@ -418,7 +422,8 @@ TEST (logging, serialization)
|
|||
logging1.max_size = 10;
|
||||
boost::property_tree::ptree tree;
|
||||
logging1.serialize_json (tree);
|
||||
rai::logging logging2 (path);
|
||||
rai::logging logging2;
|
||||
logging2.init (path);
|
||||
bool upgraded (false);
|
||||
ASSERT_FALSE (logging2.deserialize_json (upgraded, tree));
|
||||
ASSERT_FALSE (upgraded);
|
||||
|
@ -442,8 +447,10 @@ TEST (logging, upgrade_v1_v2)
|
|||
{
|
||||
auto path1 (rai::unique_path ());
|
||||
auto path2 (rai::unique_path ());
|
||||
rai::logging logging1 (path1);
|
||||
rai::logging logging2 (path2);
|
||||
rai::logging logging1;
|
||||
logging1.init (path1);
|
||||
rai::logging logging2;
|
||||
logging2.init (path2);
|
||||
boost::property_tree::ptree tree;
|
||||
logging1.serialize_json (tree);
|
||||
tree.erase ("version");
|
||||
|
@ -470,7 +477,8 @@ TEST (node, price)
|
|||
TEST (node_config, serialization)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
rai::node_config config1 (100, logging1);
|
||||
config1.bootstrap_fraction_numerator = 10;
|
||||
config1.receive_minimum = 10;
|
||||
|
@ -482,7 +490,8 @@ TEST (node_config, serialization)
|
|||
config1.callback_target = "test";
|
||||
boost::property_tree::ptree tree;
|
||||
config1.serialize_json (tree);
|
||||
rai::logging logging2 (path);
|
||||
rai::logging logging2;
|
||||
logging2.init (path);
|
||||
logging2.node_lifetime_tracing_value = !logging2.node_lifetime_tracing_value;
|
||||
rai::node_config config2 (50, logging2);
|
||||
ASSERT_NE (config2.bootstrap_fraction_numerator, config1.bootstrap_fraction_numerator);
|
||||
|
@ -512,7 +521,8 @@ TEST (node_config, serialization)
|
|||
TEST (node_config, v1_v2_upgrade)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
boost::property_tree::ptree tree;
|
||||
tree.put ("peering_port", std::to_string (0));
|
||||
tree.put ("packet_delay_microseconds", std::to_string (0));
|
||||
|
@ -528,7 +538,8 @@ TEST (node_config, v1_v2_upgrade)
|
|||
boost::property_tree::ptree preconfigured_representatives_l;
|
||||
tree.add_child ("preconfigured_representatives", preconfigured_representatives_l);
|
||||
bool upgraded (false);
|
||||
rai::node_config config1 (path);
|
||||
rai::node_config config1;
|
||||
config1.logging.init (path);
|
||||
ASSERT_FALSE (tree.get_child_optional ("work_peers"));
|
||||
config1.deserialize_json (upgraded, tree);
|
||||
ASSERT_TRUE (upgraded);
|
||||
|
@ -538,7 +549,8 @@ TEST (node_config, v1_v2_upgrade)
|
|||
TEST (node_config, unversioned_v2_upgrade)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
boost::property_tree::ptree tree;
|
||||
tree.put ("peering_port", std::to_string (0));
|
||||
tree.put ("packet_delay_microseconds", std::to_string (0));
|
||||
|
@ -559,7 +571,8 @@ TEST (node_config, unversioned_v2_upgrade)
|
|||
boost::property_tree::ptree work_peers_l;
|
||||
tree.add_child ("work_peers", work_peers_l);
|
||||
bool upgraded (false);
|
||||
rai::node_config config1 (path);
|
||||
rai::node_config config1;
|
||||
config1.logging.init (path);
|
||||
ASSERT_FALSE (tree.get_optional <std::string> ("version"));
|
||||
config1.deserialize_json (upgraded, tree);
|
||||
ASSERT_TRUE (upgraded);
|
||||
|
@ -575,7 +588,8 @@ TEST (node_config, unversioned_v2_upgrade)
|
|||
TEST (node_config, v2_v3_upgrade)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
boost::property_tree::ptree tree;
|
||||
tree.put ("peering_port", std::to_string (0));
|
||||
tree.put ("packet_delay_microseconds", std::to_string (0));
|
||||
|
@ -597,7 +611,8 @@ TEST (node_config, v2_v3_upgrade)
|
|||
boost::property_tree::ptree work_peers_l;
|
||||
tree.add_child ("work_peers", work_peers_l);
|
||||
bool upgraded (false);
|
||||
rai::node_config config1 (path);
|
||||
rai::node_config config1;
|
||||
config1.logging.init (path);
|
||||
ASSERT_FALSE (tree.get_optional <std::string> ("inactive_supply"));
|
||||
ASSERT_FALSE (tree.get_optional <std::string> ("password_fanout"));
|
||||
ASSERT_FALSE (tree.get_optional <std::string> ("io_threads"));
|
||||
|
@ -624,7 +639,8 @@ TEST (node, confirm_locked)
|
|||
TEST (node_config, random_rep)
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging1 (path);
|
||||
rai::logging logging1;
|
||||
logging1.init (path);
|
||||
rai::node_config config1 (100, logging1);
|
||||
auto rep (config1.random_representative ());
|
||||
ASSERT_NE (config1.preconfigured_representatives.end (), std::find (config1.preconfigured_representatives.begin (), config1.preconfigured_representatives.end (), rep));
|
||||
|
@ -1307,7 +1323,8 @@ TEST (node, start_observer)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging (path);
|
||||
rai::logging logging;
|
||||
logging.init (path);
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
auto node (std::make_shared <rai::node> (init, *service, 0, path, alarm, logging, work));
|
||||
auto started (false);
|
||||
|
|
|
@ -54,7 +54,8 @@ TEST (work, cancel_many)
|
|||
|
||||
TEST (work, opencl)
|
||||
{
|
||||
rai::logging logging (rai::unique_path ());
|
||||
rai::logging logging;
|
||||
logging.init (rai::unique_path ());
|
||||
auto work (rai::opencl_work::create (true, {0, 1, 1024 * 1024}, logging));
|
||||
if (work != nullptr)
|
||||
{
|
||||
|
|
|
@ -525,7 +525,7 @@ void rai::alarm::add (std::chrono::system_clock::time_point const & wakeup_a, st
|
|||
condition.notify_all ();
|
||||
}
|
||||
|
||||
rai::logging::logging (boost::filesystem::path const & application_path_a) :
|
||||
rai::logging::logging () :
|
||||
ledger_logging_value (false),
|
||||
ledger_duplicate_logging_value (false),
|
||||
vote_logging_value (false),
|
||||
|
@ -542,15 +542,18 @@ work_generation_time_value (true),
|
|||
log_to_cerr_value (false),
|
||||
max_size (16 * 1024 * 1024)
|
||||
{
|
||||
if (log_to_cerr ())
|
||||
{
|
||||
boost::log::add_console_log (std::cerr, boost::log::keywords::format = "[%TimeStamp%]: %Message%");
|
||||
}
|
||||
boost::log::add_common_attributes ();
|
||||
static bool already_added = false;
|
||||
if (!already_added)
|
||||
}
|
||||
|
||||
void rai::logging::init (boost::filesystem::path const & application_path_a)
|
||||
{
|
||||
static std::atomic_flag logging_already_added = ATOMIC_FLAG_INIT;
|
||||
if (!logging_already_added.test_and_set ())
|
||||
{
|
||||
already_added = true;
|
||||
boost::log::add_common_attributes ();
|
||||
if (log_to_cerr ())
|
||||
{
|
||||
boost::log::add_console_log (std::cerr, boost::log::keywords::format = "[%TimeStamp%]: %Message%");
|
||||
}
|
||||
boost::log::add_file_log (boost::log::keywords::target = application_path_a / "log", boost::log::keywords::file_name = application_path_a / "log" / "log_%Y-%m-%d_%H-%M-%S.%N.log", boost::log::keywords::rotation_size = 4 * 1024 * 1024, boost::log::keywords::auto_flush = true, 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%");
|
||||
}
|
||||
}
|
||||
|
@ -720,8 +723,8 @@ bool rai::node_init::error ()
|
|||
return block_store_init || wallet_init;
|
||||
}
|
||||
|
||||
rai::node_config::node_config (boost::filesystem::path const & application_path_a) :
|
||||
node_config (rai::network::node_port, rai::logging (application_path_a))
|
||||
rai::node_config::node_config () :
|
||||
node_config (rai::network::node_port, rai::logging ())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -3349,10 +3352,10 @@ rai::inactive_node::inactive_node () :
|
|||
path (rai::working_path ()),
|
||||
service (boost::make_shared <boost::asio::io_service> ()),
|
||||
alarm (*service),
|
||||
logging (path),
|
||||
work (1, nullptr)
|
||||
{
|
||||
boost::filesystem::create_directories (path);
|
||||
logging.init (path);
|
||||
node = std::make_shared <rai::node> (init, *service, 24000, path, alarm, logging, work);
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ public:
|
|||
class logging
|
||||
{
|
||||
public:
|
||||
logging (boost::filesystem::path const &);
|
||||
logging ();
|
||||
void serialize_json (boost::property_tree::ptree &) const;
|
||||
bool deserialize_json (bool &, boost::property_tree::ptree &);
|
||||
bool upgrade_json (unsigned, boost::property_tree::ptree &);
|
||||
|
@ -322,6 +322,8 @@ public:
|
|||
bool callback_logging () const;
|
||||
bool work_generation_time () const;
|
||||
bool log_to_cerr () const;
|
||||
void init (boost::filesystem::path const &);
|
||||
|
||||
bool ledger_logging_value;
|
||||
bool ledger_duplicate_logging_value;
|
||||
bool vote_logging_value;
|
||||
|
@ -350,7 +352,7 @@ public:
|
|||
class node_config
|
||||
{
|
||||
public:
|
||||
node_config (boost::filesystem::path const &);
|
||||
node_config ();
|
||||
node_config (uint16_t, rai::logging const &);
|
||||
void serialize_json (boost::property_tree::ptree &) const;
|
||||
bool deserialize_json (bool &, boost::property_tree::ptree &);
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
rai::system::system (uint16_t port_a, size_t count_a) :
|
||||
alarm (service),
|
||||
logging (rai::unique_path ()),
|
||||
work (1, nullptr)
|
||||
{
|
||||
logging.init (rai::unique_path ());
|
||||
nodes.reserve (count_a);
|
||||
for (size_t i (0); i < count_a; ++i)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
rai_daemon::daemon_config::daemon_config (boost::filesystem::path const & application_path_a) :
|
||||
rpc_enable (false),
|
||||
node (application_path_a),
|
||||
opencl_enable (false)
|
||||
{
|
||||
}
|
||||
|
@ -105,6 +104,7 @@ void rai_daemon::daemon::run (boost::filesystem::path const & data_path)
|
|||
auto error (rai::fetch_object (config, config_path, config_file));
|
||||
if (!error)
|
||||
{
|
||||
config.node.logging.init (data_path);
|
||||
config_file.close ();
|
||||
boost::asio::io_service service;
|
||||
rai::work_pool work (config.node.work_threads, rai::opencl_work::create (config.opencl_enable, config.opencl, config.node.logging));
|
||||
|
|
|
@ -15,7 +15,6 @@ class qt_wallet_config
|
|||
public:
|
||||
qt_wallet_config (boost::filesystem::path const & application_path_a) :
|
||||
account (0),
|
||||
node (application_path_a),
|
||||
rpc_enable (false),
|
||||
opencl_enable (false)
|
||||
{
|
||||
|
@ -207,6 +206,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
config_file.close ();
|
||||
if (!error)
|
||||
{
|
||||
config.node.logging.init (data_path);
|
||||
std::shared_ptr <rai::node> node;
|
||||
std::shared_ptr <rai_qt::wallet> gui;
|
||||
rai::set_application_icon (application);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue