theshell.ch/bonus2/src/ch/usi/inf/atelier/group1/util/Log.kt
bevilj 4b9169460b bonus2: complete bonus 2
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@167 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-13 22:16:49 +00:00

28 lines
643 B
Kotlin

/*
* Copyright (c) 2018 Bevilacqua Joey.
*/
package ch.usi.inf.atelier.group1.util
import java.text.SimpleDateFormat
import java.util.*
object Log {
fun e(exception: Exception) {
print('E', exception.message ?: "Unknown error", true)
}
fun i(obj: Any) {
print('I', obj.toString(), false)
}
private fun print(prefix: Char, message: String, isErr: Boolean) {
val time = SimpleDateFormat("yyyy-MM-dd hh:mm").format(Date())
if (isErr) {
System.err.println("$prefix $time\t$message")
} else {
System.out.println("$prefix $time\t$message")
}
}
}