项目作者: takayuky

项目描述 :
Typesafe Fluent Logger for Scala on top of fluent-logger-scala
高级语言: Scala
项目地址: git://github.com/takayuky/TypesafeFluentLogger.git
创建时间: 2017-05-18T04:40:51Z
项目社区:https://github.com/takayuky/TypesafeFluentLogger

开源协议:MIT License

下载


TypesafeFluentLogger

MIT License

Fluent Logger with type safety and extensibility. You can no longer pass uninteded values to loggers.

What’s wrong with fluent-logger-scala

  1. case class ShouldNotBePassedToLoggers(value: String)
  2. val shouldNotBePassedToLoggers = ShouldNotBePassedToLoggers("don't pass me to loggers")
  3. val logger: org.fluentd.logger.scala.FluentLogger
  4. logger.log("log", Map("danger" -> shouldNotBePassedToLoggers)) // You could pass literally anything.

Usage

  1. import io.github.takayuky.fluent._
  2. import io.github.takayuky.fluent.basic._
  3. val logger: TypesafeFluentLogger = TypesafeFluentLoggerFactory(tag, host, port)
  4. // TypesafeFluentLogger knows how to handle these types
  5. logger.log("success", Map(
  6. "Boolean" -> true,
  7. "Int" -> 1,
  8. "Long" -> 1L,
  9. "Double" -> 1d,
  10. "Float" -> 1f,
  11. "String" -> "hello",
  12. "BigInt" -> BigInt(1),
  13. "BigDecimal" -> BigDecimal(1),
  14. "Option" -> Some(1)
  15. ), 0L)
  16. case class ShouldNotBePassedToLoggers(value: String)
  17. val shouldNotBePassedToLoggers = ShouldNotBePassedToLoggers("don't pass me to loggers")
  18. // Compile error. You can't pass values which TypesafeFluentLoggerFactory doesn't know how to handle.
  19. logger.log("fail", Map("danger" -> shouldNotBePassedToLoggers), 0L)