mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 02:39:18 +01:00
2019 09 27 logging refactor pt2 (#765)
* Remove AKKA_CONFIG that was preventing sane logging for akka, move db-commons reference.conf to testkit so we can control testkit applications, and then rename app/server/.../application.conf to reference.conf like good libraries should do * Update contributing.md * update a few more links inside of contributing.md * Run scalafmt
This commit is contained in:
parent
f65f11aead
commit
97472930d0
8 changed files with 46 additions and 15 deletions
|
@ -19,7 +19,7 @@ Bitcoin-S includes a couple of applications that can be run as standalone execut
|
|||
This includes the node, wallet and (partial) blockchain verification modules, as well
|
||||
as the server that bundles these three together and the CLI used to communicate with
|
||||
the server. These applications are configured with HOCON files. The file
|
||||
[`reference.conf`](https://github.com/bitcoin-s/bitcoin-s/blob/master/db-commons/src/main/resources/reference.conf)
|
||||
[`reference.conf`](../testkit/src/main/resources/reference.conf)
|
||||
is the basis configuration file, and every option read by Bitcoin-S should be present in
|
||||
this file. This means that you can copy sections from this file and edit them, to tune
|
||||
how the application runs on your machine.
|
||||
|
@ -46,8 +46,10 @@ file you should edit would be `$HOME/.bitcoin-s/bitcoin-s.conf`.
|
|||
|
||||
### Running tests for the applications
|
||||
|
||||
You can place configuration files in the data directory that tests are being run in,
|
||||
but you can also edit [`reference.conf`](https://github.com/bitcoin-s/bitcoin-s/blob/master/db-commons/src/main/resources/reference.conf).
|
||||
You can place a `logback-test.xml` file in the `src/test/resources/` directory in the same project that tests are being run in.
|
||||
|
||||
If the test suite depends on `testkit`, you can modify [`reference.conf`](../testkit/src/main/resources/reference.conf)
|
||||
that is built into the testkit to control logging.
|
||||
|
||||
## Logging when working on Bitcoin-S tests
|
||||
|
||||
|
@ -66,13 +68,13 @@ pretty quickly. There's two way of doing this:
|
|||
|
||||
### Akka logging
|
||||
|
||||
The test logging for akka is controled by the [`akka.conf`](../testkit/src/main/resources/akka.conf) file inside of testkit.
|
||||
The test logging for akka is controlled by the [`reference.conf`](../testkit/src/main/resources/reference.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
|
||||
If you want to enable this when you are running a bitcoin-s application, you will need to modify the [`reference.conf`](../app/server/src/main/resources/reference.conf) file
|
||||
|
||||
## Developer productivity
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
}
|
||||
|
||||
implicit val system: ActorSystem =
|
||||
ActorSystem("EclairRpcClient", BitcoindRpcTestUtil.AKKA_CONFIG)
|
||||
ActorSystem("EclairRpcClient")
|
||||
implicit val m: ActorMaterializer = ActorMaterializer.create(system)
|
||||
implicit val ec: ExecutionContext = m.executionContext
|
||||
implicit val bitcoinNp: RegTest.type = EclairRpcTestUtil.network
|
||||
|
|
|
@ -10,7 +10,7 @@ import akka.stream.StreamTcpException
|
|||
class EclairRpcTestUtilTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
||||
|
||||
implicit private val actorSystem: ActorSystem =
|
||||
ActorSystem("EclairRpcTestUtilTest", BitcoindRpcTestUtil.AKKA_CONFIG)
|
||||
ActorSystem("EclairRpcTestUtilTest")
|
||||
|
||||
private lazy val bitcoindRpcF =
|
||||
for {
|
||||
|
|
|
@ -57,8 +57,6 @@ case class P2PClientActor(
|
|||
extends Actor
|
||||
with P2PLogger {
|
||||
|
||||
|
||||
|
||||
private var currentPeerMsgHandlerRecv = initPeerMsgHandlerReceiver
|
||||
|
||||
/**
|
||||
|
@ -107,9 +105,9 @@ case class P2PClientActor(
|
|||
handleCommand(cmd, peerOpt = None)
|
||||
|
||||
case connected: Tcp.Connected =>
|
||||
val _ = Await.result(
|
||||
handleEvent(connected, unalignedBytes = ByteVector.empty),
|
||||
timeout)
|
||||
val _ =
|
||||
Await.result(handleEvent(connected, unalignedBytes = ByteVector.empty),
|
||||
timeout)
|
||||
case msg: NetworkMessage =>
|
||||
self.forward(msg.payload)
|
||||
case payload: NetworkPayload =>
|
||||
|
|
|
@ -54,4 +54,37 @@ bitcoin-s {
|
|||
|
||||
bloomFalsePositiveRate = 0.0001 # percentage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
akka {
|
||||
loglevel = "OFF"
|
||||
stdout-loglevel = "OFF"
|
||||
http {
|
||||
client {
|
||||
# The time after which an idle connection will be automatically closed.
|
||||
# Set to `infinite` to completely disable idle connection timeouts.
|
||||
|
||||
# some requests potentially take a long time, like generate and prune
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,8 +64,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
|||
type RpcClientAccum =
|
||||
mutable.Builder[BitcoindRpcClient, Vector[BitcoindRpcClient]]
|
||||
|
||||
val AKKA_CONFIG: Config = ConfigFactory.load("akka.conf").resolve()
|
||||
|
||||
@tailrec
|
||||
private def randomDirName: String = {
|
||||
val dirname = 0.until(5).map(_ => Random.alphanumeric.head).mkString
|
||||
|
|
|
@ -35,7 +35,7 @@ abstract class BitcoindRpcTest extends AsyncFlatSpec with BeforeAndAfterAll {
|
|||
protected val logger: Logger = LoggerFactory.getLogger(getClass)
|
||||
|
||||
implicit val system: ActorSystem =
|
||||
ActorSystem(getClass.getSimpleName, BitcoindRpcTestUtil.AKKA_CONFIG)
|
||||
ActorSystem(getClass.getSimpleName)
|
||||
implicit val ec: ExecutionContext = system.dispatcher
|
||||
implicit val networkParam: NetworkParameters = BitcoindRpcTestUtil.network
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue