I'm trying to log all messages received by a TestKit TestProbe, which is proving to be somewhat difficult. I'm aware of the Actor Logging section in the docs where it says one should use the debug.receive option in combination with a LogginReceive block. This however doesn't work when I'm not in control of the actor's implementation.
The only idea I had was subclassing akka.testkit.TestActor to use a LoggingReceive and then subclass TestKit to make it create instances of my TestActor subclass instead, but that didn't work because most functionality there is private to the akka namespace (and for good reason, I suppose).
There is a (probably surprisingly) simple answer:
probe.setAutoPilot(new TestActor.AutoPilot {
def run(sender: ActorRef, msg: Any) = {
log.debug("whatever")
this
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With