Skip to content

Commit

Permalink
small change to allow pekko-actor-testkit-typed to work with slf4j-ap…
Browse files Browse the repository at this point in the history
…i v2
  • Loading branch information
pjfanning committed Nov 9, 2023
1 parent f13601d commit 64c3b47
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import pekko.actor.{ ActorPath, ActorRefProvider, InvalidMessageException }
import pekko.annotation.InternalApi
import pekko.util.Helpers
import pekko.{ actor => classic }
import org.slf4j.Logger
import org.slf4j.{ Logger, Marker }
import org.slf4j.helpers.{ MessageFormatter, SubstituteLoggerFactory }

import java.util.concurrent.ThreadLocalRandom.{ current => rnd }
Expand Down Expand Up @@ -243,11 +243,17 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
.iterator()
.asScala
.map { evt =>
val marker: Option[Marker] =
try {
Option(evt.getMarker)
} catch {
case _: NoSuchMethodError => None // evt.getMarker was replaced in slf4j v2 with evt.getMarkers
}
CapturedLogEvent(
level = evt.getLevel,
message = MessageFormatter.arrayFormat(evt.getMessage, evt.getArgumentArray).getMessage,
cause = Option(evt.getThrowable),
marker = Option(evt.getMarker))
marker = marker)
}
.toList
}
Expand Down

0 comments on commit 64c3b47

Please sign in to comment.