<commit_before>package com.beust.kobalt.misc

import com.beust.kobalt.AsciiArt
import com.beust.kobalt.KobaltException
import com.beust.kobalt.api.Kobalt
import java.text.SimpleDateFormat
import java.util.*

fun Any.log(level: Int, text: CharSequence, newLine : Boolean = true) {
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text, newLine)
    }
}

fun Any.logWrap(level: Int, text1: CharSequence, text2: CharSequence, function: () -> Unit) {
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text1, newLine = false)
    }
    function()
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text2, newLine = true)
    }
}

fun Any.debug(text: CharSequence) {
    KobaltLogger.logger.debug(javaClass.simpleName, text)
}

fun Any.warn(text: CharSequence, exception: Exception? = null) {
    KobaltLogger.logger.warn(javaClass.simpleName, text, exception)
}

fun Any.kobaltError(text: CharSequence, e: Throwable? = null) = error(text, e)

fun Any.error(text: CharSequence, e: Throwable? = null) {
    KobaltLogger.logger.error(javaClass.simpleName, text, e)
}

object KobaltLogger {
    var LOG_LEVEL: Int = 1

    val logger: Logger get() =
    if (Kobalt.context != null) {
        Logger(Kobalt.context!!.args.dev)
    } else {
        Logger(false)
    }
}

class Logger(val dev: Boolean) {
    val FORMAT = SimpleDateFormat("HH:mm:ss.SSS")

    private fun getPattern(shortTag: String, shortMessage: CharSequence, longMessage: CharSequence, tag: String) =
        if (dev) {
            val ts = FORMAT.format(Date())
            "$shortTag/$ts [" + Thread.currentThread().name + "] $tag - $shortMessage"
        } else {
            longMessage
        }

    final fun debug(tag: String, message: CharSequence) =<commit_msg>Switched from SimpleDateFormat to java.time<commit_after>package com.beust.kobalt.misc

import com.beust.kobalt.AsciiArt
import com.beust.kobalt.KobaltException
import com.beust.kobalt.api.Kobalt
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

fun Any.log(level: Int, text: CharSequence, newLine : Boolean = true) {
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text, newLine)
    }
}

fun Any.logWrap(level: Int, text1: CharSequence, text2: CharSequence, function: () -> Unit) {
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text1, newLine = false)
    }
    function()
    if (level <= KobaltLogger.LOG_LEVEL) {
        KobaltLogger.logger.log(javaClass.simpleName, text2, newLine = true)
    }
}

fun Any.debug(text: CharSequence) {
    KobaltLogger.logger.debug(javaClass.simpleName, text)
}

fun Any.warn(text: CharSequence, exception: Exception? = null) {
    KobaltLogger.logger.warn(javaClass.simpleName, text, exception)
}

fun Any.kobaltError(text: CharSequence, e: Throwable? = null) = error(text, e)

fun Any.error(text: CharSequence, e: Throwable? = null) {
    KobaltLogger.logger.error(javaClass.simpleName, text, e)
}

object KobaltLogger {
    var LOG_LEVEL: Int = 1

    val logger: Logger get() =
    if (Kobalt.context != null) {
        Logger(Kobalt.context!!.args.dev)
    } else {
        Logger(false)
    }
}

class Logger(val dev: Boolean) {
    val FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS")

    private fun getPattern(shortTag: String, shortMessage: CharSequence, longMessage: CharSequence, tag: String) =
        if (dev) {
            val ts = LocalDateTime.now().format(FORMAT)
            "$shortTag/$ts [" + Thread.currentThread().name + "] $tag - $shortMessage"
        } else {
            longMessage
        }

    final fun debug(tag: String, message: CharSequence) =
{'fraction_non_alphanumeric': 0.12447589098532495, 'fraction_numerical': 0.002620545073375262, 'mean_word_length': 3.4853113983548765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4673160', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1260, 'n_words': 266}