2018-11-12 18:16:45 +00:00
|
|
|
/*
|
2018-11-13 22:16:49 +00:00
|
|
|
* Copyright (c) 2018 Bevilacqua Joey.
|
2018-11-12 18:16:45 +00:00
|
|
|
*/
|
|
|
|
package ch.usi.inf.atelier.group1.util
|
|
|
|
|
2018-11-13 22:16:49 +00:00
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.util.*
|
2018-11-12 18:16:45 +00:00
|
|
|
|
|
|
|
object Log {
|
|
|
|
|
2018-11-13 22:16:49 +00:00
|
|
|
fun e(exception: Exception) {
|
|
|
|
print('E', exception.message ?: "Unknown error", true)
|
2018-11-12 18:16:45 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 22:16:49 +00:00
|
|
|
fun i(obj: Any) {
|
|
|
|
print('I', obj.toString(), false)
|
2018-11-12 18:16:45 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 22:16:49 +00:00
|
|
|
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")
|
|
|
|
}
|
2018-11-12 18:16:45 +00:00
|
|
|
}
|
|
|
|
}
|