当前位置: 首页>>代码示例>>Scala>>正文


Scala SLF4JBridgeHandler类代码示例

本文整理汇总了Scala中org.slf4j.bridge.SLF4JBridgeHandler的典型用法代码示例。如果您正苦于以下问题:Scala SLF4JBridgeHandler类的具体用法?Scala SLF4JBridgeHandler怎么用?Scala SLF4JBridgeHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SLF4JBridgeHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: TemperatureSensorStatic

//设置package包名称以及导入依赖的类
package net.gutefrage.basic

import com.twitter.conversions.time._
import com.twitter.finagle.ThriftMux
import com.twitter.finagle.util.DefaultTimer
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
import net.gutefrage.temperature.thrift._
import net.gutefrage.{Dtabs, Env}
import org.slf4j.bridge.SLF4JBridgeHandler


object TemperatureSensorStatic extends TwitterServer {
  val env = flag[Env]("env", Env.Local, "environment this server runs")

  premain {
    SLF4JBridgeHandler.removeHandlersForRootLogger()
    SLF4JBridgeHandler.install()

    // initialise custom dtabs
    Dtabs.init()
  }

  onExit {
    log.info("Shutting down sensor")
  }

  def main(): Unit = {
    // create a thrift client and resolve address via dtabs
    val client = ThriftMux.client.newIface[TemperatureService.FutureIface](
      // schema ! args
      dest = s"zk2!127.0.0.1:2181!/service/${env().name}/temperature",
      label = "temperature-sensor"
    )

    implicit val timer = DefaultTimer.twitter
    val randomTemp = new java.util.Random()

    def sendLoop: Future[Unit] = {
      val datum = TemperatureDatum(randomTemp.nextInt(40) - 10,
                                   System.currentTimeMillis / 1000)
      log.info(s"Sending data: $datum")
      for {
        _ <- Future.sleep(1.second)
        _ <- client.add(datum)
        _ <- sendLoop
      } yield ()
    }

    Await.ready(sendLoop)
  }

} 
开发者ID:gutefrage,项目名称:the-finagle-docs,代码行数:54,代码来源:TemperatureSensorStatic.scala

示例2: failfastOnFlagsNotParsed

//设置package包名称以及导入依赖的类
package net.gutefrage.basic

import com.twitter.app.Flaggable
import com.twitter.conversions.time._
import com.twitter.finagle.{Dtab, ThriftMux}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
import net.gutefrage.temperature.thrift._
import net.gutefrage.{Dtabs, Env}
import org.slf4j.bridge.SLF4JBridgeHandler


  override def failfastOnFlagsNotParsed: Boolean = true

  premain {
    SLF4JBridgeHandler.removeHandlersForRootLogger()
    SLF4JBridgeHandler.install()

    // initialise custom dtabs
    Dtabs.init(baseDtab())
    log.info(
      s"""|Use base dtab:
          |${Dtab.base.show}
       """.stripMargin)
  }

  onExit {
    log.info("Shutting down sensor")
  }

  def main(): Unit = {
    // create a thrift client and resolve address via dtabs
    val client = ThriftMux.client.newIface[TemperatureService.FutureIface](
      dest = "/s/temperature",
      label = "temperature-sensor"
    )

    implicit val timer = DefaultTimer.twitter
    val randomTemp = new java.util.Random()

    def sendLoop: Future[Unit] = {
      val datum = TemperatureDatum(randomTemp.nextInt(40) - 10,
                                   System.currentTimeMillis / 1000)
      log.info(s"Sending data: $datum")
      for {
        _ <- Future.sleep(1.second)
        _ <- client.add(datum)
        _ <- sendLoop
      } yield ()
    }

    Await.ready(sendLoop)
  }

} 
开发者ID:gutefrage,项目名称:the-finagle-docs,代码行数:57,代码来源:TemperatureSensorDtabs.scala

示例3: ActorPathFreeSpec

//设置package包名称以及导入依赖的类
package com.pagerduty.scheduler.specutil

import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import com.typesafe.config.ConfigFactory
import org.scalatest.{Matchers, path}
import org.slf4j.bridge.SLF4JBridgeHandler

abstract class ActorPathFreeSpec(actorSystemName: String)
    extends TestKit(ActorSystem(actorSystemName, ConfigFactory.load().getConfig("scheduler")))
    // New actor system per test!? And, how do we shut it down?!
    with ImplicitSender
    with path.FreeSpecLike
    with Matchers {
  LoggingUtil.initJavaUtilLoggingBridge()
}

object LoggingUtil {
  def initJavaUtilLoggingBridge(): Unit = {
    initJavaUtilLoggingBridgeOnce
  }
  private lazy val initJavaUtilLoggingBridgeOnce = redirectJavaUtilLogging()
  private def redirectJavaUtilLogging(): Unit = {
    SLF4JBridgeHandler.removeHandlersForRootLogger()
    SLF4JBridgeHandler.install()
  }
} 
开发者ID:PagerDuty,项目名称:scheduler,代码行数:28,代码来源:ActorPathFreeSpec.scala

示例4: canInstallBridgeHandler

//设置package包名称以及导入依赖的类
package com.twitter.util.logging

import com.twitter.concurrent.Once
import org.slf4j.LoggerFactory
import org.slf4j.bridge.SLF4JBridgeHandler


  private def canInstallBridgeHandler: Boolean = {
    try {
      Class.forName("org.slf4j.impl.JDK14LoggerFactory", false, this.getClass.getClassLoader)
      LoggerFactory
        .getLogger(this.getClass)
        .warn("Detected [org.slf4j.impl.JDK14LoggerFactory] on classpath. " +
          "SLF4JBridgeHandler cannot be installed, see: http://www.slf4j.org/legacy.html#julRecursion")
      false
    } catch {
      case e: ClassNotFoundException =>
        true
    }
  }
} 
开发者ID:lanshuijuntuan,项目名称:Java.util,代码行数:22,代码来源:Slf4jBridgeUtility.scala


注:本文中的org.slf4j.bridge.SLF4JBridgeHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。