From d1f75cdfef2ba90dd2f3d3c344806fc2487fdfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mamy=20Andr=C3=A9-Ratsimbazafy?= Date: Tue, 26 Mar 2019 10:56:23 +0100 Subject: [PATCH] Improve distinction between debugging stacktraces and crash/exception stacktraces --- beacon_chain/gossipsub_protocol.nim | 7 +++++-- beacon_chain/tracing/stacktraces.nim | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 beacon_chain/tracing/stacktraces.nim diff --git a/beacon_chain/gossipsub_protocol.nim b/beacon_chain/gossipsub_protocol.nim index 1302519b0..d2d485c17 100644 --- a/beacon_chain/gossipsub_protocol.nim +++ b/beacon_chain/gossipsub_protocol.nim @@ -2,7 +2,8 @@ import tables, sets, macros, base64, chronos, nimcrypto/sysrand, chronicles, json_serialization, eth/[p2p, rlp], eth/p2p/[rlpx, peer_pool], - spec/[datatypes, crypto] + spec/[datatypes, crypto], + tracing/stacktraces type TopicMsgHandler = proc (msg: string) @@ -38,7 +39,9 @@ p2pProtocol GossipSub(version = 1, onPeerDisconnected do (peer: Peer, reason: DisconnectionReason): info "GossipSub Peer disconnected", peer, reason - writeStackTrace() + debug "Debugging stacktrace" + writeStyledStackTrace() + debug "Continuing ..." proc subscribeFor(peer: Peer, topic: string) = peer.state.subscribedFor.incl topic diff --git a/beacon_chain/tracing/stacktraces.nim b/beacon_chain/tracing/stacktraces.nim new file mode 100644 index 000000000..465faea65 --- /dev/null +++ b/beacon_chain/tracing/stacktraces.nim @@ -0,0 +1,12 @@ +# beacon_chain +# Copyright (c) 2018-2019 Status Research & Development GmbH +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +import terminal + +proc writeStyledStackTrace*() = + let st = getStackTrace() + writeStyled st, style = {styleBright, styleItalic} \ No newline at end of file