<commit_before>package org.opennms.core.utils;

import java.util.Properties;

import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;

public class LogUtils {
    public static void tracef(final Object logee, final String format, final Object... args) {
        tracef(logee, null, format, args);
    }

    public static void tracef(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isTraceEnabled()) {
            if (throwable == null) {
                log.trace(String.format(format, args));
            } else {
                log.trace(String.format(format, args), throwable);
            }
        }
    }

    public static void debugf(final Object logee, final String format, final Object... args) {
        debugf(logee, null, format, args);
    }

    public static void debugf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isDebugEnabled()) {
            if (throwable == null) {
                log.debug(String.format(format, args));
            } else {
                log.debug(String.format(format, args), throwable);
            }
        }
    }

    public static void infof(final Object logee, final String format, final Object... args) {
        infof(logee, null, format, args);
    }

    public static void infof(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isInfoEnabled()) {
            if (throwable == null) {
                log.info(String.format(format, args));
            } else {
                log.info(String.format(format, args), throwable);
            }
        }
    }

    public static void warnf(final Object logee, final String format, final Object... args) {
        warnf(logee, null, format, args);
    }

    public static void warnf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isWarnEnabled()) {
            if (throwable == null) {
                log.warn(String.format(format, args));
            } else {
                log.warn(String.format(format, args), throwable);
            }
        }
    }

    public static void errorf(final Object logee, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void errorf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isErrorEnabled()) {
            if (throwable == null) {
                log.error(String.format(format, args));
            } else {
                log.error(String.format(format, args), throwable);
            }
        }
    }

    public static void fatalf(final Object logee, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void fatalf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void logToConsole() {
    	final Properties logConfig = new Properties();<commit_msg>Changed LogUtils so that it will only attempt to use String.format() if there are expansion parameters provided to the logging call.<commit_after>package org.opennms.core.utils;

import java.util.Properties;

import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;

public class LogUtils {
    public static void tracef(final Object logee, final String format, final Object... args) {
        tracef(logee, null, format, args);
    }

    public static void tracef(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isTraceEnabled()) {
            String logMessage = ((args == null || args.length < 1) ? format : String.format(format, args));
            if (throwable == null) {
                log.trace(logMessage);
            } else {
                log.trace(logMessage, throwable);
            }
        }
    }

    public static void debugf(final Object logee, final String format, final Object... args) {
        debugf(logee, null, format, args);
    }

    public static void debugf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isDebugEnabled()) {
            String logMessage = ((args == null || args.length < 1) ? format : String.format(format, args));
            if (throwable == null) {
                log.debug(logMessage);
            } else {
                log.debug(logMessage, throwable);
            }
        }
    }

    public static void infof(final Object logee, final String format, final Object... args) {
        infof(logee, null, format, args);
    }

    public static void infof(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isInfoEnabled()) {
            String logMessage = ((args == null || args.length < 1) ? format : String.format(format, args));
            if (throwable == null) {
                log.info(logMessage);
            } else {
                log.info(logMessage, throwable);
            }
        }
    }

    public static void warnf(final Object logee, final String format, final Object... args) {
        warnf(logee, null, format, args);
    }

    public static void warnf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isWarnEnabled()) {
            String logMessage = ((args == null || args.length < 1) ? format : String.format(format, args));
            if (throwable == null) {
                log.warn(logMessage);
            } else {
                log.warn(logMessage, throwable);
            }
        }
    }

    public static void errorf(final Object logee, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void errorf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        Logger log = getLogger(logee);
        if (log.isErrorEnabled()) {
            String logMessage = ((args == null || args.length < 1) ? format : String.format(format, args));
            if (throwable == null) {
                log.error(logMessage);
            } else {
                log.error(logMessage, throwable);
            }
        }
    }

    public static void fatalf(final Object logee, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void fatalf(final Object logee, final Throwable throwable, final String format, final Object... args) {
        errorf(logee, null, format, args);
    }

    public static void logToConsole() {
    	final Properties logConfig = new Properties();
{'fraction_non_alphanumeric': 0.10788266370082024, 'fraction_numerical': 0.0012512164604476575, 'mean_word_length': 2.191659272404614, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '4151556', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1914, 'n_words': 614}