mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-21 13:23:05 +01:00
Use scala-logging
This commit is contained in:
committed by
Yevhen Zadyra
parent
07172866d9
commit
de3c2ad9b1
@@ -1,4 +1,5 @@
|
||||
dependencies {
|
||||
api "ch.qos.logback:logback-classic:1.2.11"
|
||||
api "org.typelevel:cats-core_$scala:2.8.0"
|
||||
api "com.typesafe.scala-logging:scala-logging_$scala:3.9.5"
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
package com.lbs.common
|
||||
|
||||
import org.slf4j
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
trait Logger {
|
||||
private val log: slf4j.Logger = LoggerFactory.getLogger(this.getClass)
|
||||
|
||||
protected def debug(msg: => String): Unit = {
|
||||
if (log.isDebugEnabled)
|
||||
log.debug(msg)
|
||||
}
|
||||
|
||||
protected def warn(msg: => String): Unit = {
|
||||
if (log.isWarnEnabled)
|
||||
log.warn(msg)
|
||||
}
|
||||
|
||||
protected def warn(msg: => String, throwable: Throwable): Unit = {
|
||||
if (log.isWarnEnabled)
|
||||
log.warn(msg, throwable)
|
||||
}
|
||||
|
||||
protected def error(msg: => String): Unit = {
|
||||
if (log.isErrorEnabled)
|
||||
log.error(msg)
|
||||
}
|
||||
|
||||
protected def error(msg: => String, throwable: Throwable): Unit = {
|
||||
if (log.isErrorEnabled)
|
||||
log.error(msg, throwable)
|
||||
}
|
||||
|
||||
protected def info(msg: => String): Unit = {
|
||||
if (log.isInfoEnabled)
|
||||
log.info(msg)
|
||||
}
|
||||
|
||||
protected def trace(msg: => String): Unit = {
|
||||
if (log.isTraceEnabled)
|
||||
log.trace(msg)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
package com.lbs.common
|
||||
|
||||
import com.typesafe.scalalogging.LazyLogging
|
||||
|
||||
import java.util.concurrent.{Executors, ScheduledFuture}
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
|
||||
class Scheduler(poolSize: Int) extends Logger {
|
||||
class Scheduler(poolSize: Int) extends LazyLogging {
|
||||
private val scheduledThreadPool = Executors.newScheduledThreadPool(poolSize)
|
||||
|
||||
def schedule(fn: => Unit, period: FiniteDuration): ScheduledFuture[_] = {
|
||||
@@ -22,7 +24,7 @@ class Scheduler(poolSize: Int) extends Logger {
|
||||
fn
|
||||
} catch {
|
||||
case ex: Exception =>
|
||||
error(s"Unable to execute scheduler task", ex)
|
||||
logger.error(s"Unable to execute scheduler task", ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user