Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit e7dc0b0

Browse files
committed
Address PR feedback
Move some log messages from error to warning verbosity, make boost log attribute configuration more compact, and use m_id.hex() rather than first writing the value to a stream.
1 parent 6fc1b80 commit e7dc0b0

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

libethereum/EthereumCapability.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,13 +842,13 @@ bool EthereumCapability::interpretCapabilityPacket(
842842
}
843843
catch (Exception const&)
844844
{
845-
LOG(m_loggerError) << "Peer " << _peerID << " causing an exception: "
846-
<< boost::current_exception_diagnostic_information() << " " << _r;
845+
LOG(m_loggerWarn) << "Peer " << _peerID << " causing an exception: "
846+
<< boost::current_exception_diagnostic_information() << " " << _r;
847847
}
848848
catch (std::exception const& _e)
849849
{
850-
LOG(m_loggerError) << "Peer " << _peerID << " causing an exception: " << _e.what() << " "
851-
<< _r;
850+
LOG(m_loggerWarn) << "Peer " << _peerID << " causing an exception: " << _e.what() << " "
851+
<< _r;
852852
}
853853

854854
return true;

libethereum/EthereumCapability.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class EthereumCapability : public p2p::CapabilityFace
191191
Logger m_logger{createLogger(VerbosityDebug, "ethcap")};
192192
Logger m_loggerDetail{createLogger(VerbosityTrace, "ethcap")};
193193
Logger m_loggerError{createLogger(VerbosityError, "ethcap")};
194+
Logger m_loggerWarn{createLogger(VerbosityWarning, "ethcap")};
194195
/// Logger for messages about impolite behaivour of peers.
195196
Logger m_loggerImpolite{createLogger(VerbosityDebug, "impolite")};
196197
};

libethereum/EthereumPeer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ class EthereumPeer
2222
u256 const& /*_capabilityVersion*/)
2323
: m_host(std::move(_host)), m_id(_peerID)
2424
{
25-
std::stringstream remoteInfoStream;
26-
remoteInfoStream << m_id;
27-
m_logger.add_attribute(
28-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
25+
m_logger.add_attribute("Suffix", boost::log::attributes::constant<std::string>{m_id.hex()});
2926
}
3027

3128
bool statusReceived() const { return m_protocolVersion != 0; }

libp2p/Session.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ Session::Session(Host* _h, unique_ptr<RLPXFrameCoder>&& _io, std::shared_ptr<RLP
2727
stringstream remoteInfoStream;
2828
remoteInfoStream << "(" << m_info.id << "@" << m_socket->remoteEndpoint() << ")";
2929

30-
m_netLogger.add_attribute(
31-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
32-
m_netLoggerDetail.add_attribute(
33-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
34-
m_netLoggerError.add_attribute(
35-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
36-
37-
m_capLogger.add_attribute(
38-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
39-
m_capLoggerDetail.add_attribute(
40-
"Suffix", boost::log::attributes::constant<std::string>(remoteInfoStream.str()));
30+
auto const attr = boost::log::attributes::constant<std::string>{remoteInfoStream.str()};
31+
m_netLogger.add_attribute("Suffix", attr);
32+
m_netLoggerDetail.add_attribute("Suffix", attr);
33+
m_netLoggerError.add_attribute("Suffix", attr);
34+
35+
m_capLogger.add_attribute("Suffix", attr);
36+
m_capLoggerDetail.add_attribute("Suffix", attr);
4137

4238
m_peer->m_lastDisconnect = NoDisconnect;
4339
m_lastReceived = m_connect = chrono::steady_clock::now();
@@ -126,9 +122,9 @@ bool Session::readPacket(uint16_t _capId, unsigned _packetType, RLP const& _r)
126122
}
127123
catch (std::exception const& _e)
128124
{
129-
LOG(m_netLoggerError) << "Exception caught in p2p::Session::readPacket(): " << _e.what()
130-
<< ". PacketType: " << capabilityPacketTypeToString(_packetType)
131-
<< " (" << _packetType << "). RLP: " << _r;
125+
LOG(m_netLogger) << "Exception caught in p2p::Session::readPacket(): " << _e.what()
126+
<< ". PacketType: " << capabilityPacketTypeToString(_packetType) << " ("
127+
<< _packetType << "). RLP: " << _r;
132128
disconnect(BadProtocol);
133129
return true;
134130
}
@@ -330,7 +326,7 @@ void Session::doRead()
330326
return;
331327
else if (!m_io->authAndDecryptHeader(bytesRef(m_data.data(), length)))
332328
{
333-
LOG(m_netLoggerError) << "Header decrypt failed";
329+
LOG(m_netLogger) << "Header decrypt failed";
334330
drop(BadProtocol); // todo: better error
335331
return;
336332
}

0 commit comments

Comments
 (0)