Skip to content

Commit

Permalink
Merge pull request #9 from chris-hatton/dev/0.0.3-LambdaSignatures
Browse files Browse the repository at this point in the history
Dev/0.0.3 lambda signatures
  • Loading branch information
AAkira authored May 19, 2019
2 parents b088c53 + 6540650 commit 1360b1e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions napier/src/commonMain/kotlin/com/github/aakira/napier/Napier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,60 @@ object Napier {
log(Level.VERBOSE, tag, throwable, message)
}

fun v(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.VERBOSE, tag, throwable, message)
}

fun i(message: String, throwable: Throwable? = null, tag: String? = null) {
log(Level.INFO, tag, throwable, message)
}

fun i(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.INFO, tag, throwable, message)
}

fun d(message: String, throwable: Throwable? = null, tag: String? = null) {
log(Level.DEBUG, tag, throwable, message)
}

fun d(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.DEBUG, tag, throwable, message)
}

fun w(message: String, throwable: Throwable? = null, tag: String? = null) {
log(Level.WARNING, tag, throwable, message)
}

fun w(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.WARNING, tag, throwable, message)
}

fun e(message: String, throwable: Throwable? = null, tag: String? = null) {
log(Level.ERROR, tag, throwable, message)
}

fun e(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.ERROR, tag, throwable, message)
}

fun wtf(message: String, throwable: Throwable? = null, tag: String? = null) {
log(Level.ASSERT, tag, throwable, message)
}

fun wtf(message: ()->String, throwable: Throwable? = null, tag: String? = null) {
log(Level.ASSERT, tag, throwable, message)
}

fun log(priority: Level, tag: String? = null, throwable: Throwable? = null, message: String) {
if (isEnable(priority, tag)) {
rawLog(priority, tag, throwable, message)
}
}

fun log(priority: Level, tag: String? = null, throwable: Throwable? = null, message: ()->String) {
if (isEnable(priority, tag)) {
rawLog(priority, tag, throwable, message())
}
}
}

0 comments on commit 1360b1e

Please sign in to comment.