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

in.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. Deprecation Notice for group ID "in.specmatic" ****************************************************************************************************** Updates for "specmatic-core" will no longer be available under the deprecated group ID "in.specmatic". Please update your dependencies to use the new group ID "io.specmatic". ******************************************************************************************************

The newest version!
package `in`.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