All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.specmatic.core.log.Logging.kt Maven / Gradle / Ivy

Go to download

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.

There is a newer version: 2.0.37
Show newest version
package io.specmatic.core.log

var logger: LogStrategy = newLogger()
fun newLogger(): LogStrategy = ThreadSafeLog(NonVerbose(CompositePrinter()))
fun resetLogger() {
    logger = NonVerbose(CompositePrinter())
}

fun logException(fn: ()-> Unit): Int {
    return try {
        fn()
        0
    } catch(e: Throwable) {
        logger.log(e)
        1
    }
}

fun consoleLog(event: String) {
    consoleLog(StringLog(event))
}

fun consoleLog(event: LogMessage) {
    LogTail.append(event)
    logger.log(event)
}

fun consoleLog(e: Throwable) {
    LogTail.append(logger.ofTheException(e))
    logger.log(e)
}

fun consoleLog(e: Throwable, msg: String) {
    LogTail.append(logger.ofTheException(e, msg))
    logger.log(e, msg)
}

val dontPrintToConsole = { event: LogMessage ->
    LogTail.append(event)
}

val ignoreLog = { _: LogMessage -> }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy