From cb2d5110ffad04915a8e4936705c4c202f58d981 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 1 Aug 2017 10:39:36 +0100 Subject: [PATCH] Tweak net logs so we get more info on why networking can't start This should prevent "silent" failures to start --- contrib/epee/src/mlog.cpp | 2 +- src/p2p/net_node.inl | 44 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 2ac3138f9..a3f38e677 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -91,7 +91,7 @@ static const char *get_default_categories(int level) switch (level) { case 0: - categories = "*:WARNING,net:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO"; + categories = "*:WARNING,net:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO"; break; case 1: categories = "*:WARNING,global:INFO,stacktrace:INFO,logging:INFO,msgwriter:INFO"; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 58a7f3563..a4d9fee95 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -159,7 +159,7 @@ namespace nodetool } catch (const std::exception &e) { - LOG_ERROR("Failed to load p2p config file, falling back to default config"); + MWARNING("Failed to load p2p config file, falling back to default config"); m_peerlist = peerlist_manager(); // it was probably half clobbered by the failed load make_default_config(); } @@ -396,7 +396,7 @@ namespace nodetool } else { - MERROR("IPv6 unsupported, skip '" << host << "' -> " << endpoint.address().to_v6().to_string(ec)); + MWARNING("IPv6 unsupported, skip '" << host << "' -> " << endpoint.address().to_v6().to_string(ec)); throw std::runtime_error("IPv6 unsupported"); } } @@ -756,19 +756,19 @@ namespace nodetool if(code < 0) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } if(rsp.node_data.network_id != m_network_id) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection."); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection."); return; } if(!handle_remote_peerlist(rsp.local_peerlist_new, rsp.node_data.local_time, context)) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE: failed to handle_remote_peerlist(...), closing connection."); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE: failed to handle_remote_peerlist(...), closing connection."); add_host_fail(context.m_remote_address); return; } @@ -777,7 +777,7 @@ namespace nodetool { if(!m_payload_handler.process_payload_sync_data(rsp.payload_data, context, true)) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection."); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection."); hsh_result = false; return; } @@ -805,7 +805,7 @@ namespace nodetool if(!hsh_result) { - LOG_ERROR_CC(context_, "COMMAND_HANDSHAKE Failed"); + LOG_WARNING_CC(context_, "COMMAND_HANDSHAKE Failed"); m_net_server.get_config_object().close(context_.m_connection_id); } else @@ -831,7 +831,7 @@ namespace nodetool context.m_in_timedsync = false; if(code < 0) { - LOG_ERROR_CC(context, "COMMAND_TIMED_SYNC invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); + LOG_WARNING_CC(context, "COMMAND_TIMED_SYNC invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } @@ -848,7 +848,7 @@ namespace nodetool if(!r) { - LOG_ERROR_CC(context_, "COMMAND_TIMED_SYNC Failed"); + LOG_WARNING_CC(context_, "COMMAND_TIMED_SYNC Failed"); return false; } return true; @@ -1383,17 +1383,17 @@ namespace nodetool uint64_t time_delata = local_time > tr.time ? local_time - tr.time: tr.time - local_time; if(time_delata > 24*60*60 ) { - LOG_ERROR("check_trust failed to check time conditions, local_time=" << local_time << ", proof_time=" << tr.time); + MWARNING("check_trust failed to check time conditions, local_time=" << local_time << ", proof_time=" << tr.time); return false; } if(m_last_stat_request_time >= tr.time ) { - LOG_ERROR("check_trust failed to check time conditions, last_stat_request_time=" << m_last_stat_request_time << ", proof_time=" << tr.time); + MWARNING("check_trust failed to check time conditions, last_stat_request_time=" << m_last_stat_request_time << ", proof_time=" << tr.time); return false; } if(m_config.m_peer_id != tr.peer_id) { - LOG_ERROR("check_trust failed: peer_id mismatch (passed " << tr.peer_id << ", expected " << m_config.m_peer_id<< ")"); + MWARNING("check_trust failed: peer_id mismatch (passed " << tr.peer_id << ", expected " << m_config.m_peer_id<< ")"); return false; } crypto::public_key pk = AUTO_VAL_INIT(pk); @@ -1401,7 +1401,7 @@ namespace nodetool crypto::hash h = get_proof_of_trust_hash(tr); if(!crypto::check_signature(h, pk, tr.sign)) { - LOG_ERROR("check_trust failed: sign check failed"); + MWARNING("check_trust failed: sign check failed"); return false; } //update last request time @@ -1562,13 +1562,13 @@ namespace nodetool { if(code <= 0) { - LOG_ERROR_CC(ping_context, "Failed to invoke COMMAND_PING to " << address.str() << "(" << code << ", " << epee::levin::get_err_descr(code) << ")"); + LOG_WARNING_CC(ping_context, "Failed to invoke COMMAND_PING to " << address.str() << "(" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } if(rsp.status != PING_OK_RESPONSE_STATUS_TEXT || pr != rsp.peer_id) { - LOG_ERROR_CC(ping_context, "back ping invoke wrong response \"" << rsp.status << "\" from" << address.str() << ", hsh_peer_id=" << pr_ << ", rsp.peer_id=" << rsp.peer_id); + LOG_WARNING_CC(ping_context, "back ping invoke wrong response \"" << rsp.status << "\" from" << address.str() << ", hsh_peer_id=" << pr_ << ", rsp.peer_id=" << rsp.peer_id); m_net_server.get_config_object().close(ping_context.m_connection_id); return; } @@ -1578,7 +1578,7 @@ namespace nodetool if(!inv_call_res) { - LOG_ERROR_CC(ping_context, "back ping invoke failed to " << address.str()); + LOG_WARNING_CC(ping_context, "back ping invoke failed to " << address.str()); m_net_server.get_config_object().close(ping_context.m_connection_id); return false; } @@ -1586,7 +1586,7 @@ namespace nodetool }); if(!r) { - LOG_ERROR_CC(context, "Failed to call connect_async, network error."); + LOG_WARNING_CC(context, "Failed to call connect_async, network error."); } return r; } @@ -1605,7 +1605,7 @@ namespace nodetool { if(code < 0) { - LOG_ERROR_CC(context_, "COMMAND_REQUEST_SUPPORT_FLAGS invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); + LOG_WARNING_CC(context_, "COMMAND_REQUEST_SUPPORT_FLAGS invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } @@ -1622,7 +1622,7 @@ namespace nodetool { if(!m_payload_handler.process_payload_sync_data(arg.payload_data, context, false)) { - LOG_ERROR_CC(context, "Failed to process_payload_sync_data(), dropping connection"); + LOG_WARNING_CC(context, "Failed to process_payload_sync_data(), dropping connection"); drop_connection(context); return 1; } @@ -1649,7 +1649,7 @@ namespace nodetool if(!context.m_is_income) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came not from incoming connection"); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came not from incoming connection"); drop_connection(context); add_host_fail(context.m_remote_address); return 1; @@ -1657,14 +1657,14 @@ namespace nodetool if(context.peer_id) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came, but seems that connection already have associated peer_id (double COMMAND_HANDSHAKE?)"); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came, but seems that connection already have associated peer_id (double COMMAND_HANDSHAKE?)"); drop_connection(context); return 1; } if(!m_payload_handler.process_payload_sync_data(arg.payload_data, context, true)) { - LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came, but process_payload_sync_data returned false, dropping connection."); + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came, but process_payload_sync_data returned false, dropping connection."); drop_connection(context); return 1; }