mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-12 10:30:19 +01:00
Add akka logging documentation to our contributing.md (#764)
This commit is contained in:
parent
4ee36e84e9
commit
5d28e9143d
5 changed files with 59 additions and 36 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue