aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/LogInterceptor.scala
blob: b5b8a79c28c05549f65bb7d4089002d2ce84ff1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package kamon

import uk.org.lidalia.slf4jext.Level
import uk.org.lidalia.slf4jtest.{LoggingEvent, TestLogger}

trait LogInterceptor {

  def interceptLog[T](level: Level)(code: => T)(implicit tl: TestLogger): Seq[LoggingEvent] = {
    import scala.collection.JavaConverters._
    tl.clear()
    val run = code
    tl.getLoggingEvents().asScala.filter(_.getLevel == level)
  }
}