Skip to content

Commit

Permalink
Logging improvements (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored and clemahieu committed Apr 18, 2018
1 parent 306bf51 commit 70fbf8c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions rai/node/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void rai::bootstrap_client::run ()
switch (ec.value ())
{
default:
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("Error initiating bootstrap connection to %2%: %1%") % ec.message () % this_l->endpoint);
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("Error initiating bootstrap connection to %1%: %2%") % this_l->endpoint % ec.message ());
break;
case boost::system::errc::connection_refused:
case boost::system::errc::operation_canceled:
Expand Down Expand Up @@ -545,7 +545,7 @@ void rai::bulk_pull_client::request ()
{
if (this_l->connection->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error sending bulk pull request %1% to %2%") % ec.message () % this_l->connection->endpoint);
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error sending bulk pull request to %1%: to %2%") % ec.message () % this_l->connection->endpoint);
}
}
});
Expand All @@ -565,7 +565,7 @@ void rai::bulk_pull_client::receive_block ()
{
if (this_l->connection->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ());
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error receiving block type: %1%") % ec.message ());
}
}
});
Expand Down Expand Up @@ -723,7 +723,7 @@ void rai::bulk_push_client::start ()
{
if (this_l->connection->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Unable to send bulk_push request %1%") % ec.message ());
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Unable to send bulk_push request: %1%") % ec.message ());
}
}
});
Expand Down Expand Up @@ -806,7 +806,7 @@ void rai::bulk_push_client::push_block (rai::block const & block_a)
{
if (this_l->connection->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error sending block during bulk push %1%") % ec.message ());
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error sending block during bulk push: %1%") % ec.message ());
}
}
});
Expand Down Expand Up @@ -1545,7 +1545,7 @@ void rai::bootstrap_server::receive_header_action (boost::system::error_code con
{
if (node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (node->log) << boost::str (boost::format ("Error while receiving type %1%") % ec.message ());
BOOST_LOG (node->log) << boost::str (boost::format ("Error while receiving type: %1%") % ec.message ());
}
}
}
Expand Down Expand Up @@ -1609,7 +1609,7 @@ void rai::bootstrap_server::receive_frontier_req_action (boost::system::error_co
{
if (node->config.logging.network_logging ())
{
BOOST_LOG (node->log) << boost::str (boost::format ("Error sending receiving frontier request %1%") % ec.message ());
BOOST_LOG (node->log) << boost::str (boost::format ("Error sending receiving frontier request: %1%") % ec.message ());
}
}
}
Expand Down Expand Up @@ -2051,7 +2051,7 @@ void rai::bulk_push_server::receive ()
{
if (this_l->connection->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ());
BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error receiving block type: %1%") % ec.message ());
}
}
});
Expand Down Expand Up @@ -2212,7 +2212,7 @@ void rai::frontier_req_server::no_block_sent (boost::system::error_code const &
{
if (connection->node->config.logging.network_logging ())
{
BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier finish %1%") % ec.message ());
BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier finish: %1%") % ec.message ());
}
}
}
Expand All @@ -2227,7 +2227,7 @@ void rai::frontier_req_server::sent_action (boost::system::error_code const & ec
{
if (connection->node->config.logging.network_logging ())
{
BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier pair %1%") % ec.message ());
BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier pair: %1%") % ec.message ());
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions rai/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void rai::network::send_keepalive (rai::endpoint const & endpoint_a)
{
if (ec && node_l->config.logging.network_keepalive_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error sending keepalive to %1% %2%") % endpoint_a % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error sending keepalive to %1%: %2%") % endpoint_a % ec.message ());
}
}
});
Expand All @@ -115,7 +115,7 @@ void rai::node::keepalive (std::string const & address_a, uint16_t port_a)
}
else
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error resolving address: %1%:%2%, %3%") % address_a % port_a % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error resolving address: %1%:%2%: %3%") % address_a % port_a % ec.message ());
}
});
}
Expand All @@ -133,7 +133,7 @@ void rai::network::republish (rai::block_hash const & hash_a, std::shared_ptr<st
{
if (ec && node_l->config.logging.network_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error sending publish: %1% to %2%") % ec.message () % endpoint_a);
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error sending publish to %1%: %2%") % endpoint_a % ec.message ());
}
}
});
Expand Down Expand Up @@ -1336,7 +1336,7 @@ rai::process_return rai::block_processor::process_receive_one (MDB_txn * transac
{
std::string block;
block_a->serialize_json (block);
BOOST_LOG (node.log) << boost::str (boost::format ("Processing block %1% %2%") % block_a->hash ().to_string () % block);
BOOST_LOG (node.log) << boost::str (boost::format ("Processing block %1%: %2%") % block_a->hash ().to_string () % block);
}
break;
}
Expand Down Expand Up @@ -1567,7 +1567,7 @@ online_reps (*this)
{
if (node_l->config.logging.callback_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable complete callback: %1%:%2% %3%") % address % port % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable complete callback: %1%:%2%: %3%") % address % port % ec.message ());
}
};
});
Expand All @@ -1576,7 +1576,7 @@ online_reps (*this)
{
if (node_l->config.logging.callback_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to send callback: %1%:%2% %3%") % address % port % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to send callback: %1%:%2%: %3%") % address % port % ec.message ());
}
}
});
Expand All @@ -1585,7 +1585,7 @@ online_reps (*this)
{
if (node_l->config.logging.callback_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to connect to callback address: %1%:%2%, %3%") % address % port % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to connect to callback address: %1%:%2%: %3%") % address % port % ec.message ());
}
}
});
Expand All @@ -1595,7 +1595,7 @@ online_reps (*this)
{
if (node_l->config.logging.callback_logging ())
{
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error resolving callback: %1%:%2%, %3%") % address % port % ec.message ());
BOOST_LOG (node_l->log) << boost::str (boost::format ("Error resolving callback: %1%:%2%: %3%") % address % port % ec.message ());
}
}
});
Expand Down Expand Up @@ -2307,19 +2307,19 @@ class distributed_work : public std::enable_shared_from_this<distributed_work>
}
else
{
BOOST_LOG (node->log) << boost::str (boost::format ("Incorrect work response from %1% for root %2% value %3%") % address % root.to_string () % work_text);
BOOST_LOG (node->log) << boost::str (boost::format ("Incorrect work response from %1% for root %2%: %3%") % address % root.to_string () % work_text);
handle_failure (last);
}
}
else
{
BOOST_LOG (node->log) << boost::str (boost::format ("Work response from %1% wasn't a number %2%") % address % work_text);
BOOST_LOG (node->log) << boost::str (boost::format ("Work response from %1% wasn't a number: %2%") % address % work_text);
handle_failure (last);
}
}
catch (...)
{
BOOST_LOG (node->log) << boost::str (boost::format ("Work response from %1% wasn't parsable %2%") % address % body_a);
BOOST_LOG (node->log) << boost::str (boost::format ("Work response from %1% wasn't parsable: %2%") % address % body_a);
handle_failure (last);
}
}
Expand Down Expand Up @@ -4038,7 +4038,7 @@ void rai::port_mapping::refresh_devices ()
}
if (check_count % 15 == 0)
{
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP local address: %3%, discovery: %1%, IGD search: %2%") % discover_error % igd_error % local_address.data ());
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP local address: %1%, discovery: %2%, IGD search: %3%") % local_address.data () % discover_error % igd_error);
for (auto i (devices); i != nullptr; i = i->pNext)
{
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP device url: %1% st: %2% usn: %3%") % i->descURL % i->st % i->usn);
Expand All @@ -4062,7 +4062,7 @@ void rai::port_mapping::refresh_mapping ()
auto add_port_mapping_error (UPNP_AddAnyPortMapping (urls.controlURL, data.first.servicetype, node_port.c_str (), node_port.c_str (), address.to_string ().c_str (), nullptr, protocol.name, nullptr, std::to_string (mapping_timeout).c_str (), actual_external_port.data ()));
if (check_count % 15 == 0)
{
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP %1% port mapping response: %2%, actual external port %5%") % protocol.name % add_port_mapping_error % 0 % 0 % actual_external_port.data ());
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP %1% port mapping response: %2%, actual external port %3%") % protocol.name % add_port_mapping_error % actual_external_port.data ());
}
if (add_port_mapping_error == UPNPCOMMAND_SUCCESS)
{
Expand Down Expand Up @@ -4114,7 +4114,7 @@ int rai::port_mapping::check_mapping ()
}
if (check_count % 15 == 0)
{
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP %3% mapping verification response: %1%, external ip response: %6%, external ip: %4%, internal ip: %5%, remaining lease: %2%") % verify_port_mapping_error % remaining_mapping_duration.data () % protocol.name % external_address.data () % address.to_string () % external_ip_error);
BOOST_LOG (node.log) << boost::str (boost::format ("UPnP %1% mapping verification response: %2%, external ip response: %3%, external ip: %4%, internal ip: %5%, remaining lease: %6%") % protocol.name % verify_port_mapping_error % external_ip_error % external_address.data () % address.to_string () % remaining_mapping_duration.data ());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rai/node/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2329,14 +2329,14 @@ void rai::rpc_handler::payment_begin ()
wallet->free_accounts.erase (existing);
if (wallet->store.find (transaction, account) == wallet->store.end ())
{
BOOST_LOG (node.log) << boost::str (boost::format ("Transaction wallet %1% externally modified listing account %1% as free but no longer exists") % id.to_string () % account.to_account ());
BOOST_LOG (node.log) << boost::str (boost::format ("Transaction wallet %1% externally modified listing account %2% as free but no longer exists") % id.to_string () % account.to_account ());
account.clear ();
}
else
{
if (!node.ledger.account_balance (transaction, account).is_zero ())
{
BOOST_LOG (node.log) << boost::str (boost::format ("Skipping account %1% for use as a transaction account since it's balance isn't zero") % account.to_account ());
BOOST_LOG (node.log) << boost::str (boost::format ("Skipping account %1% for use as a transaction account: non-zero balance") % account.to_account ());
account.clear ();
}
}
Expand Down

0 comments on commit 70fbf8c

Please sign in to comment.