<commit_before>package com.crossbowffs.quotelock.utils

import android.util.Log
import com.crossbowffs.quotelock.BuildConfig


private const val LOG_TAG = BuildConfig.LOG_TAG
private const val LOG_LEVEL = BuildConfig.LOG_LEVEL
private const val LOG_TO_XPOSED = BuildConfig.LOG_TO_XPOSED

inline fun <reified T> className(): String {
    return T::class.simpleName ?: T::class.java.simpleName
}

object Xlog {
    private fun log(priority: Int, tag: String?, message: String, vararg args: Any) {
        if (priority < LOG_LEVEL) {
            return
        }
        var msg = String.format(message, *args)
        if (args.isNotEmpty() && args[args.size - 1] is Throwable) {
            val throwable = args[args.size - 1] as Throwable
            val stacktraceStr = Log.getStackTraceString(throwable)
            msg = """
                $msg
                $stacktraceStr
                """.trimIndent()
        }
        Log.println(priority, LOG_TAG, "${tag?.let { "$it:" }} $msg")
        if (LOG_TO_XPOSED) {
            Log.println(priority, "Xposed", "$LOG_TAG: ${tag?.let { "$it: " }}$msg")
        }
    }

    fun v(tag: String?, message: String, vararg args: Any) {
        log(Log.VERBOSE, tag, message, *args)
    }

    fun d(tag: String?, message: String, vararg args: Any) {
        log(Log.DEBUG, tag, message, *args)
    }

    fun i(tag: String?, message: String, vararg args: Any) {
        log(Log.INFO, tag, message, *args)
    }

    fun w(tag: String?, message: String, vararg args: Any) {
        log(Log.WARN, tag, message, *args)
    }

    fun e(tag: String?, message: String, vararg args: Any) {
        log(Log.ERROR, tag, message, *args)
    }
}<commit_msg>Fixed the UnknownFormatConversionException caused by log messages containing '%' character but no format arguments passed in.<commit_after>package com.crossbowffs.quotelock.utils

import android.util.Log
import com.crossbowffs.quotelock.BuildConfig


private const val LOG_TAG = BuildConfig.LOG_TAG
private const val LOG_LEVEL = BuildConfig.LOG_LEVEL
private const val LOG_TO_XPOSED = BuildConfig.LOG_TO_XPOSED

inline fun <reified T> className(): String {
    return T::class.simpleName ?: T::class.java.simpleName
}

object Xlog {
    private fun log(priority: Int, tag: String?, message: String, vararg args: Any) {
        if (priority < LOG_LEVEL) {
            return
        }
        val msg = if (args.isNotEmpty()) {
            String.format(message, *args).let {
                if (args[args.size - 1] is Throwable) {
                    val throwable = args[args.size - 1] as Throwable
                    val stacktraceStr = Log.getStackTraceString(throwable)
                    "$it\n$stacktraceStr"
                } else {
                    it
                }
            }
        } else {
            message
        }
        Log.println(priority, LOG_TAG, "${tag?.let { "$it:" }} $msg")
        if (LOG_TO_XPOSED) {
            Log.println(priority, "Xposed", "$LOG_TAG: ${tag?.let { "$it: " }}$msg")
        }
    }

    fun v(tag: String?, message: String, vararg args: Any) {
        log(Log.VERBOSE, tag, message, *args)
    }

    fun d(tag: String?, message: String, vararg args: Any) {
        log(Log.DEBUG, tag, message, *args)
    }

    fun i(tag: String?, message: String, vararg args: Any) {
        log(Log.INFO, tag, message, *args)
    }

    fun w(tag: String?, message: String, vararg args: Any) {
        log(Log.WARN, tag, message, *args)
    }

    fun e(tag: String?, message: String, vararg args: Any) {
        log(Log.ERROR, tag, message, *args)
    }
}
{'fraction_non_alphanumeric': 0.12555555555555556, 'fraction_numerical': 0.0011111111111111111, 'mean_word_length': 2.343546889507892, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4820674', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1118, 'n_words': 302}