Skip to content

Commit

Permalink
update ConsoleWriter (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrimaeon authored Oct 30, 2021
1 parent fe46d3f commit dea6444
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions kermit/src/jsMain/kotlin/co/touchlab/kermit/ConsoleWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,15 @@ package co.touchlab.kermit

class ConsoleWriter : LogWriter() {
override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
console.log(severity.name, tag, message)
var output = "[$tag] $message"
throwable?.let {
output += " ${it.stackTraceToString()}"
}
when (severity) {
Severity.Assert, Severity.Error -> console.error(output)
Severity.Warn -> console.warn(output)
Severity.Info -> console.info(output)
Severity.Debug, Severity.Verbose -> console.log(output)
}
}

override fun v(message: String, tag: String, throwable: Throwable?) {
console.log(tag, message, throwable)
}

override fun d(message: String, tag: String, throwable: Throwable?) {
console.log(tag, message, throwable)
}

override fun i(message: String, tag: String, throwable: Throwable?) {
console.info(tag, message, throwable)
}

override fun w(message: String, tag: String, throwable: Throwable?) {
console.warn(tag, message, throwable)
}

override fun e(message: String, tag: String, throwable: Throwable?) {
console.error(tag, message, throwable)
}

override fun a(message: String, tag: String, throwable: Throwable?) {
console.error(tag, message, throwable)
}
}
}

0 comments on commit dea6444

Please sign in to comment.