diff --git a/app/server/src/main/resources/application.conf b/app/server/src/main/resources/application.conf index 2693385658..fc8127e425 100644 --- a/app/server/src/main/resources/application.conf +++ b/app/server/src/main/resources/application.conf @@ -1,3 +1,22 @@ akka { + loglevel = "INFO" + stdout-loglevel = "OFF" + + actor { + debug { + # enable DEBUG logging of all AutoReceiveMessages (Kill, PoisonPill etc.) + autoreceive= off + # enable function of LoggingReceive, which is to log any received message at + # DEBUG level + receive = on + # enable DEBUG logging of unhandled messages + unhandled = off + + # enable DEBUG logging of actor lifecycle changes + lifecycle = off + + event-stream=off + } + } } \ No newline at end of file diff --git a/docs/contributing.md b/docs/contributing.md index 8c23c2a4cb..f7cd67a8c8 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -64,6 +64,16 @@ pretty quickly. There's two way of doing this: output less noisy. You can tune this by changing the level found in `core-test/src/test/resources/logback-test.xml`. +### Akka logging + +The test logging for akka is controled by the [`akka.conf`](../testkit/src/main/resources/akka.conf) file inside of testkit. + +This allows you to debug what is happening in our actors inside of bitcoin-s easier. For examples of what you can enable for akka to log, please look at their [logging documentation](https://doc.akka.io/docs/akka/current/logging.html#auxiliary-logging-options) + +The easiest thing to do to enable akka logging is to adjust the `loglevel` and `stdout-loglevel` from `OFF` to `DEBUG`. + +If you want to enable this when you are running a bitcoin-s application, you will need to modify the [`application.conf`](../app/server/src/main/resources/application.conf) file + ## Developer productivity ### Bloop diff --git a/node/src/main/resources/application.conf b/node/src/main/resources/application.conf deleted file mode 100644 index ce9d8020e5..0000000000 --- a/node/src/main/resources/application.conf +++ /dev/null @@ -1,25 +0,0 @@ -bitcoin-s { - network = regtest -} - -akka { - loglevel = "OFF" - - # Log the complete configuration at INFO level when the actor system is started. - # This is useful when you are uncertain of what configuration is used. - # log-config-on-start = on - - actor { - debug { - # enable function of LoggingReceive, which is to log any received message at - # DEBUG level - receive = on - - # enable DEBUG logging of unhandled messages - unhandled = on - - # enable DEBUG logging of all LoggingFSMs for events, transitions and timers - fsm = on - } - } -} diff --git a/node/src/main/scala/org/bitcoins/node/networking/P2PClient.scala b/node/src/main/scala/org/bitcoins/node/networking/P2PClient.scala index f37ed3bda9..41dd1c3bdb 100644 --- a/node/src/main/scala/org/bitcoins/node/networking/P2PClient.scala +++ b/node/src/main/scala/org/bitcoins/node/networking/P2PClient.scala @@ -1,25 +1,24 @@ package org.bitcoins.node.networking import akka.actor.{Actor, ActorRef, ActorRefFactory, Props} +import akka.event.LoggingReceive import akka.io.{IO, Tcp} import akka.util.{ByteString, CompactByteString, Timeout} import org.bitcoins.core.config.NetworkParameters -import org.bitcoins.core.p2p.NetworkMessage -import org.bitcoins.core.p2p.NetworkPayload +import org.bitcoins.core.p2p.{NetworkMessage, NetworkPayload} import org.bitcoins.core.util.FutureUtil +import org.bitcoins.node.P2PLogger +import org.bitcoins.node.config.NodeAppConfig import org.bitcoins.node.models.Peer import org.bitcoins.node.networking.peer.PeerMessageReceiver import org.bitcoins.node.networking.peer.PeerMessageReceiver.NetworkMessageReceived import org.bitcoins.node.util.BitcoinSpvNodeUtil import scodec.bits.ByteVector -import org.bitcoins.node.config.NodeAppConfig import scala.annotation.tailrec -import scala.util._ -import org.bitcoins.node.P2PLogger - -import scala.concurrent.{Await, ExecutionContext, Future} import scala.concurrent.duration.DurationInt +import scala.concurrent.{Await, ExecutionContext, Future} +import scala.util._ /** * This actor is responsible for creating a connection, @@ -58,6 +57,8 @@ case class P2PClientActor( extends Actor with P2PLogger { + + private var currentPeerMsgHandlerRecv = initPeerMsgHandlerReceiver /** @@ -81,7 +82,7 @@ case class P2PClientActor( */ private def awaitNetworkRequest( peer: ActorRef, - unalignedBytes: ByteVector): Receive = { + unalignedBytes: ByteVector): Receive = LoggingReceive { case message: NetworkMessage => sendNetworkMessage(message, peer) case payload: NetworkPayload => val networkMsg = NetworkMessage(network, payload) @@ -96,7 +97,7 @@ case class P2PClientActor( } /** This context is responsible for initializing a tcp connection with a peer on the bitcoin p2p network */ - def receive: Receive = { + def receive: Receive = LoggingReceive { case cmd: Tcp.Command => //we only accept a Tcp.Connect/Tcp.Connected //message to the default receive on this actor @@ -353,8 +354,8 @@ object P2PClient extends P2PLogger { peerMessageReceiver: PeerMessageReceiver)( implicit config: NodeAppConfig): P2PClient = { val actorRef = context.actorOf( - props(peer = peer, peerMsgHandlerReceiver = peerMessageReceiver), - BitcoinSpvNodeUtil.createActorName(this.getClass)) + props = props(peer = peer, peerMsgHandlerReceiver = peerMessageReceiver), + name = BitcoinSpvNodeUtil.createActorName(getClass)) P2PClient(actorRef, peer) } diff --git a/testkit/src/main/resources/akka.conf b/testkit/src/main/resources/akka.conf index 8af763a5bd..a459c0fbec 100644 --- a/testkit/src/main/resources/akka.conf +++ b/testkit/src/main/resources/akka.conf @@ -10,4 +10,22 @@ akka { idle-timeout = 5 minutes } } + + + actor { + debug { + # enable DEBUG logging of all AutoReceiveMessages (Kill, PoisonPill etc.) + autoreceive= off + # enable function of LoggingReceive, which is to log any received message at + # DEBUG level + receive = on + # enable DEBUG logging of unhandled messages + unhandled = off + + # enable DEBUG logging of actor lifecycle changes + lifecycle = off + + event-stream=off + } + } } \ No newline at end of file