All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.malliina.logback.formatting.scala Maven / Gradle / Ivy

There is a newer version: 2.8.0
Show newest version
package com.malliina.logback

import ch.qos.logback.core.{AppenderBase, CoreConstants}

object LogbackFormatting extends LogbackFormatting

trait LogbackFormatting {
  val defaultFormatter = new TimeFormatter(CoreConstants.ISO8601_PATTERN)

  def defaultFormat(time: Long): String = defaultFormatter.format(time)
}

trait TimeFormatting[E] extends AppenderBase[E] {
  private var formatter: TimeFormatter = LogbackFormatting.defaultFormatter

  def getTimeFormat: String = formatter.timeFormat

  def setTimeFormat(format: String): Unit = {
    formatter = new TimeFormatter(format)
    addInfo(s"Time format set to ${formatter.timeFormat}")
  }

  def format(timeStamp: Long) = formatter.format(timeStamp)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy