From fe724251011c177aabdf2810dfb5d4eb3a97852c Mon Sep 17 00:00:00 2001 From: Andrei Pozolotin Date: Wed, 3 Dec 2014 10:27:17 -0600 Subject: + system-metrics: two-phase sigar loading * update slf4jVersion * redirect JUL and LOG4J logging to SLF4J * use two-phase sigar loading --- .../test/scala/kamon/metrics/RedirectLogging.scala | 34 ++++++++++++++++++++++ .../scala/kamon/metrics/SystemMetricsSpec.scala | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 kamon-system-metrics/src/test/scala/kamon/metrics/RedirectLogging.scala (limited to 'kamon-system-metrics/src/test/scala/kamon/metrics') diff --git a/kamon-system-metrics/src/test/scala/kamon/metrics/RedirectLogging.scala b/kamon-system-metrics/src/test/scala/kamon/metrics/RedirectLogging.scala new file mode 100644 index 00000000..fbf42cf0 --- /dev/null +++ b/kamon-system-metrics/src/test/scala/kamon/metrics/RedirectLogging.scala @@ -0,0 +1,34 @@ +/* ========================================================================================= + * Copyright © 2013-2014 the kamon project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.metric + +import java.util.logging.LogManager +import org.slf4j.bridge.SLF4JBridgeHandler + +/** + * Redirect different logging sources to SLF4J. + */ +trait RedirectLogging { + + def redirectLogging(): Unit = { + // Redirect JUL to SLF4J. + LogManager.getLogManager().reset(); + SLF4JBridgeHandler.install(); + } + + redirectLogging() + +} diff --git a/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala b/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala index 058dafb4..714a1e6d 100644 --- a/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala +++ b/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala @@ -33,7 +33,7 @@ import org.scalatest.{ Matchers, WordSpecLike } import scala.concurrent.duration._ -class SystemMetricsSpec extends TestKitBase with WordSpecLike with Matchers { +class SystemMetricsSpec extends TestKitBase with WordSpecLike with Matchers with RedirectLogging { implicit lazy val system: ActorSystem = ActorSystem("system-metrics-spec", ConfigFactory.parseString( """ |akka { -- cgit v1.2.3