Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reintroduce a removed implicit logger and deprecate it #352

Merged
merged 3 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = ()
}
}