1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-24 06:47:46 +01:00
eclair/eclair-core
Pierre-Marie Padiou 3568dd6c17
Rework log capture in tests (#2409)
This PR enables capturing and printing logs for tests that failed, and is compatible with parallel testing. The core idea is to use a different `LoggerContext` for each test (see [logback's doc on context selection](https://logback.qos.ch/manual/contextSelector.html)).

Actual capture and printing of logs is realized through the same technique as Akka's builtin `LogCapture` helpers, that is: 
- a custom appender accumulates log events in memory
- a dedicated logger (defined in logback-test.xml and disabled by default) is manually called by the custom appender when logs need to be printed

I unfortunately had to introduce boilerplate classes `MyContextSelector`, `MySlf4jLogger` and `MyCapturingAppender`, the last two being tweaked versions of Akka's existing classes.

Note that the log capture is only enabled for tests that use `FixtureSpec`. The `ActorSystem` needs to be configured to log to `MySlf4jLogger`.

Advantages over existing technique:
- compatible with parallel testing
- no funny business with reflection in FixtureSpec.scala
- use configuratble logback formatting instead of raw println
- allows logging from lightning-kmp (depends on https://github.com/ACINQ/lightning-kmp/pull/355)

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2022-09-06 10:43:59 +02:00
..
src Rework log capture in tests (#2409) 2022-09-06 10:43:59 +02:00
eclair-cli Dual funding RBF support (#2275) 2022-08-22 14:37:48 +02:00
pom.xml Update sqlite to 3.39.2.0 (#2369) 2022-08-09 14:31:03 +02:00