From 90c7747222cf5ea8993a27dea10a7ca30da2c947 Mon Sep 17 00:00:00 2001 From: dufrannea Date: Tue, 26 Sep 2017 14:57:00 +0200 Subject: [PATCH] Adds default logger to package (#172) --- core/src/main/scala/com/criteo/cuttle/Logging.scala | 10 ---------- core/src/main/scala/com/criteo/cuttle/package.scala | 10 +++++++++- .../scala/com/criteo/cuttle/examples/HelloWorld.scala | 1 - .../com/criteo/cuttle/timeseries/TimeSeriesSpec.scala | 1 - 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/core/src/main/scala/com/criteo/cuttle/Logging.scala b/core/src/main/scala/com/criteo/cuttle/Logging.scala index f602ea468..eabfff7a6 100644 --- a/core/src/main/scala/com/criteo/cuttle/Logging.scala +++ b/core/src/main/scala/com/criteo/cuttle/Logging.scala @@ -5,14 +5,4 @@ trait Logger { def info(message: => String): Unit def warning(message: => String): Unit def error(message: => String): Unit -} - -object default { - implicit val logger = new Logger { - def logMe(message : => String, level: String) = println(s"${java.time.Instant.now}\t${level}\t${message}") - override def info(message: => String): Unit = logMe(message, "INFO") - override def debug(message: => String): Unit = logMe(message, "DEBUG") - override def warning(message: => String): Unit = () - override def error(message : => String): Unit = () - } } \ No newline at end of file diff --git a/core/src/main/scala/com/criteo/cuttle/package.scala b/core/src/main/scala/com/criteo/cuttle/package.scala index 3ca952d44..c14e71f80 100644 --- a/core/src/main/scala/com/criteo/cuttle/package.scala +++ b/core/src/main/scala/com/criteo/cuttle/package.scala @@ -3,6 +3,7 @@ package com.criteo import scala.concurrent._ import doobie.imports._ import cats.free._ +import cuttle.logging.Logger package cuttle { sealed trait Completed @@ -17,5 +18,12 @@ package object cuttle { type SideEffect[S <: Scheduling] = (Execution[S]) => Future[Completed] implicit def scopedExecutionContext(implicit execution: Execution[_]) = execution.executionContext - + + implicit val logger = new Logger { + def logMe(message : => String, level: String) = println(s"${java.time.Instant.now}\t${level}\t${message}") + override def info(message: => String): Unit = logMe(message, "INFO") + override def debug(message: => String): Unit = logMe(message, "DEBUG") + override def warning(message: => String): Unit = () + override def error(message : => String): Unit = () + } } diff --git a/examples/src/main/scala/com/criteo/cuttle/examples/HelloWorld.scala b/examples/src/main/scala/com/criteo/cuttle/examples/HelloWorld.scala index 42e78e825..9f8503b30 100644 --- a/examples/src/main/scala/com/criteo/cuttle/examples/HelloWorld.scala +++ b/examples/src/main/scala/com/criteo/cuttle/examples/HelloWorld.scala @@ -1,7 +1,6 @@ package com.criteo.cuttle.examples import com.criteo.cuttle._ -import com.criteo.cuttle.logging.default._ import platforms.local._ import timeseries._ diff --git a/timeseries/src/test/scala/com/criteo/cuttle/timeseries/TimeSeriesSpec.scala b/timeseries/src/test/scala/com/criteo/cuttle/timeseries/TimeSeriesSpec.scala index 297e51685..df2ae05c8 100644 --- a/timeseries/src/test/scala/com/criteo/cuttle/timeseries/TimeSeriesSpec.scala +++ b/timeseries/src/test/scala/com/criteo/cuttle/timeseries/TimeSeriesSpec.scala @@ -1,7 +1,6 @@ package com.criteo.cuttle.timeseries import com.criteo.cuttle._ -import com.criteo.cuttle.logging.default.logger import org.scalatest.FunSuite import java.time._ import java.time.temporal.ChronoUnit._