src/main/scala/s3/website/Logger.scala in s3_website_monadic-0.0.37 vs src/main/scala/s3/website/Logger.scala in s3_website_monadic-0.0.38
- old
+ new
@@ -1,19 +1,21 @@
package s3.website
-class Logger(val verboseOutput: Boolean, logMessage: (String) => Unit = println) {
+import scala.util.Try
+
+class Logger(val verboseOutput: Boolean) {
def debug(msg: String) = if (verboseOutput) log(Debug, msg)
def info(msg: String) = log(Info, msg)
def fail(msg: String) = log(Failure, msg)
def info(report: SuccessReport) = log(Success, report.reportMessage)
def info(report: FailureReport) = fail(report.reportMessage)
def pending(msg: String) = log(Wait, msg)
- private def log(logType: LogType, msgRaw: String) {
+ private def log(logType: LogType, msgRaw: String): Try[Unit] = {
val msg = msgRaw.replaceAll("\\n", "\n ") // Indent new lines, so that they arrange nicely with other log lines
- logMessage(s"[$logType] $msg")
+ Try(println(s"[$logType] $msg"))
}
sealed trait LogType {
val prefix: String
override def toString = prefix
\ No newline at end of file