<commit_before>package org.hcjf.log;

import org.hcjf.properties.SystemProperties;
import org.hcjf.service.Service;
import org.hcjf.utils.Strings;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.stream.Stream;

/**
 * Static class that contains the funcionality in order to
 * maintain and organize a log file with the same records format
 * The log behavior is affected by the following system properties
 * <br><b>hcfj_log_path</b>: work directory of the log, by default app work directory
 * <br><b>hcfj_log_initial_queue_size</b>: initial size of the internal queue, by default 10000;
 * <br><b>hcfj_log_file_prefix</b>: all the log files start with this prefix, by default hcjf
 * <br><b>hcfj_log_error_file</b>: if the property is true then log create a particular file for error group only, by default false
 * <br><b>hcfj_log_warning_file</b>: if the property is true then log create a particular file for warning group only, by default false
 * <br><b>hcfj_log_info_file</b>: if the property is true then log create a particular file for info group only, by default false
 * <br><b>hcfj_log_debug_file</b>: if the property is true then log create a particular file for debug group only, by default false
 * <br><b>hcfj_log_level</b>: min level to write file, by default "I"
 * <br><b>hcfj_log_date_format</b>: date format to show in the log file, by default "yyyy-mm-dd hh:mm:ss"
 * @author javaito
 * @email <EMAIL>
 */
public final class Log extends Service<LogPrinter> {

    private static final Log instance;

    static {
        instance = new Log();
    }

    private final List<LogPrinter> printers;
    private final Queue<LogRecord> queue;
    private final Object logMonitor;
    private Future future;

    /**
     * Private constructor
     */
    private Log() {
        super(SystemProperties.get(SystemProperties.Log.SERVICE_NAME),
                SystemProperties.getInteger(SystemProperties.Log.SERVICE_PRIORITY));
        this.printers = new ArrayList<>();
        this.queue = new PriorityBlockingQueue<>(
                SystemProperties.getInteger(SystemProperties.Log.QUEUE_INITIAL_SIZE),
                (o1, o2) -> (int)(o1.getDate().getTime() - o2.getDate().getTime()));
        this.logMonitor = new Object();
    }

    /**
     * Start the log thread.
     */
    @Override
    protected void init() {
        for (int i = 0; i < SystemProperties.getInteger(SystemProperties.Log.SERVICE_NAME); i++) {
            future = fork(new LogRunnable());
        }
        List<String> logConsumers = SystemProperties.getList(SystemProperties.Log.CONSUMERS);
        logConsumers.forEach(S -> {
            try {<commit_msg>Adding fixed number of consumer to print the log record<commit_after>package org.hcjf.log;

import org.hcjf.properties.SystemProperties;
import org.hcjf.service.Service;
import org.hcjf.utils.Strings;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.stream.Stream;

/**
 * Static class that contains the funcionality in order to
 * maintain and organize a log file with the same records format
 * The log behavior is affected by the following system properties
 * <br><b>hcfj_log_path</b>: work directory of the log, by default app work directory
 * <br><b>hcfj_log_initial_queue_size</b>: initial size of the internal queue, by default 10000;
 * <br><b>hcfj_log_file_prefix</b>: all the log files start with this prefix, by default hcjf
 * <br><b>hcfj_log_error_file</b>: if the property is true then log create a particular file for error group only, by default false
 * <br><b>hcfj_log_warning_file</b>: if the property is true then log create a particular file for warning group only, by default false
 * <br><b>hcfj_log_info_file</b>: if the property is true then log create a particular file for info group only, by default false
 * <br><b>hcfj_log_debug_file</b>: if the property is true then log create a particular file for debug group only, by default false
 * <br><b>hcfj_log_level</b>: min level to write file, by default "I"
 * <br><b>hcfj_log_date_format</b>: date format to show in the log file, by default "yyyy-mm-dd hh:mm:ss"
 * @author javaito
 * @email <EMAIL>
 */
public final class Log extends Service<LogPrinter> {

    private static final Log instance;

    static {
        instance = new Log();
    }

    private final List<LogPrinter> printers;
    private final Queue<LogRecord> queue;
    private final Object logMonitor;
    private Future future;

    /**
     * Private constructor
     */
    private Log() {
        super(SystemProperties.get(SystemProperties.Log.SERVICE_NAME),
                SystemProperties.getInteger(SystemProperties.Log.SERVICE_PRIORITY));
        this.printers = new ArrayList<>();
        this.queue = new PriorityBlockingQueue<>(
                SystemProperties.getInteger(SystemProperties.Log.QUEUE_INITIAL_SIZE),
                (o1, o2) -> (int)(o1.getDate().getTime() - o2.getDate().getTime()));
        this.logMonitor = new Object();
    }

    /**
     * Start the log thread.
     */
    @Override
    protected void init() {
        for (int i = 0; i < SystemProperties.getInteger(SystemProperties.Log.LOG_CONSUMERS_SIZE); i++) {
            future = fork(new LogRunnable());
        }
        List<String> logConsumers = SystemProperties.getList(SystemProperties.Log.CONSUMERS);
        logConsumers.forEach(S -> {
            try {
{'fraction_non_alphanumeric': 0.10245614035087719, 'fraction_numerical': 0.0035087719298245615, 'mean_word_length': 3.6124595469255665, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 75, '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': '7189122', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1658, 'n_words': 529}