<commit_before>package com.indeed.proctor.store;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

/**
 * java.io.PrintWriter adapter foor org.apache.log4j.Logger.
 */
class LoggerPrintWriter extends PrintWriter {
    public LoggerPrintWriter(final Logger logger, final Level level) {
        super(new InternalLoggerWriter(logger, level));
    }

    static class InternalLoggerWriter extends Writer {

        final Logger logger;
        final Level level;

        InternalLoggerWriter(final Logger logger, final Level level) {
            this.logger = logger;
            this.level = level;
        }

        @Override
        public void write(char[] cbuf, int off, int len) throws IOException {
            // Remove leading carriage returns inserted by jgit
            if (cbuf[off] == '\r') {
                off++;
                len--;
            }
            logger.log(level, String.copyValueOf(cbuf, off, len));
        }
<commit_msg>PROC-184: Only process log when logger is enabled<commit_after>package com.indeed.proctor.store;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

/**
 * java.io.PrintWriter adapter for org.apache.log4j.Logger.
 */
class LoggerPrintWriter extends PrintWriter {
    public LoggerPrintWriter(final Logger logger, final Level level) {
        super(new InternalLoggerWriter(logger, level));
    }

    static class InternalLoggerWriter extends Writer {

        final Logger logger;
        final Level level;

        InternalLoggerWriter(final Logger logger, final Level level) {
            this.logger = logger;
            this.level = level;
        }

        @Override
        public void write(char[] cbuf, int off, int len) throws IOException {
            if (logger.isEnabledFor(level)) {
                // Remove leading carriage returns inserted by jgit
                if (cbuf[off] == '\r') {
                    off++;
                    len--;
                }
                logger.log(level, String.copyValueOf(cbuf, off, len));
            }
        }

{'fraction_non_alphanumeric': 0.09418657052726453, 'fraction_numerical': 0.00405588102748986, 'mean_word_length': 2.1988472622478388, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1568770', 'n_tokens_mistral': 600, 'n_tokens_neox': 581, 'n_words': 165}