Skip to content

Commit

Permalink
reintroduce a removed implicit logger and deprecate it (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryshev authored Jan 28, 2019
1 parent 01c83b4 commit 22b2948
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
val devMode = settingKey[Boolean]("Some build optimization are applied in devMode.")
val writeClasspath = taskKey[File]("Write the project classpath to a file.")

val VERSION = "0.5.4"
val VERSION = "0.5.5"

lazy val catsCore = "1.5.0"
lazy val circe = "0.10.1"
Expand Down
15 changes: 14 additions & 1 deletion core/src/main/scala/com/criteo/cuttle/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package cuttle {
* - [[Scheduler]] is defined for a given [[Scheduling]] mechanism.
* - [[Execution]]s are created by a [[Scheduler]] for a given [[Job]] and [[SchedulingContext]].
* - [[Executor]] handles the [[SideEffect]]s execution.
* - [[SideEffect]]s are plain asynchronous Scala functions and can use [[ExecutionPlatform]]s to
* - [[SideEffect]]s are plain asynchronous Scala functions and can use [[com.criteo.cuttle.ExecutionPlatform]]s to
* access underlying resources.
*/
package object cuttle {
Expand All @@ -43,6 +43,7 @@ package object cuttle {
type XA = Transactor[IO]
private[cuttle] val NoUpdate: ConnectionIO[Int] = Free.pure(0)


/** The side effect function represents the real job execution. It returns a `Future[Completed]` to
* indicate the execution result (we use [[Completed]] here instead of `Unit` to avoid automatic value
* discarding, but [[Completed]] do not maintain additional state).
Expand All @@ -61,4 +62,16 @@ package object cuttle {
*/
implicit def scopedExecutionContext(implicit execution: Execution[_]): ExecutionContext = execution.executionContext

/** Default implicit logger that output everything to __stdout__ */
@deprecated("Global implicits are bad, this implementation will be removed in a next version, please switch to yours.", "01/28/2019")
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 warn(message: => String): Unit = logMe(message, "WARN")
def warning(message: => String): Unit = logMe(message, "WARNING")
override def error(message: => String): Unit = logMe(message, "ERROR")
override def trace(message: => String): Unit = ()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package object examples {
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 warn(message: => String): Unit = logMe(message, "WARNING")
override def warn(message: => String): Unit = logMe(message, "WARN")
override def error(message: => String): Unit = logMe(message, "ERROR")
override def trace(message: => String): Unit = logMe(message, "TRACE")
override def trace(message: => String): Unit = ()
}
}

0 comments on commit 22b2948

Please sign in to comment.