<commit_before>package com.github.mnicky.bible4j;

import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

import org.slf4j.LoggerFactory;

import com.github.mnicky.bible4j.cli.CommandParser;
import com.github.mnicky.bible4j.storage.H2DbBibleStorageFactory;

/**
 * Main class of the application, which starts the application.
 *
 */
public final class AppRunner {
    
    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(AppRunner.AppLogger.class);
    
    /**
     * This class has disabled instantiating
     */
    private AppRunner() {}
    
    /**
     * Main method of the application, collecting commandline Arguments and starting the Application 
     * @param args commandline arguments
     */
    public static void main(String[] args) {

	try {
	    AppLogger.setUpLoggers(Level.OFF, new ConsoleHandler());
	    CommandParser cp = new CommandParser(new H2DbBibleStorageFactory());
	    cp.launch(args);
	} catch (Exception e) {
	    // for user
	    System.out.println("Error: " + e.getMessage());
	    // for log
	    logger.error("Exception caught", e);
	}

    }

    /**
     * Name of this class is used as Logger name for all classes of this Application and this class is also responsible for setting the Logger level
     * and logging handler.
     *
     */
    public static class AppLogger {
	
	private final static org.slf4j.Logger logger = LoggerFactory.getLogger(AppRunner.AppLogger.class);
	
	private static Level level = null;
	private static Handler handler = null;
	
	private static final String LOG_LEVEL_PROPERTY_NAME = "log.level";
	private static final String LOG_FILE_PROPERTY_NAME = "log.file";

	/**
	 * Sets the default log handler and log level for Logger used in bible4j.
	 * This method also checks for presence of system properties 'log.level',
	 * and 'log.file' and if exists, their value overrides default logging settings.
	 */
	public static void setUpLoggers(Level defaultLevel, Handler defaultHandler) {
	    level = defaultLevel;
	    handler = defaultHandler;
	    getLoggingProperties();
	    
	    //reset logger
	    Logger appLogger = Logger.getLogger(AppRunner.AppLogger.class.getName());
	    LogManager.getLogManager().reset();
	    
	    //set logger settings
	    appLogger.setLevel(level);
	    handler.setLevel(level);
	    appLogger.addHandler(handler);
	    LogManager.getLogManager().addLogger(appLogger);
	}

	private static void getLoggingProperties() {
	    if (System.getProperty(LOG_LEVEL_PROPERTY_NAME) != null)
		try {
		    level = Level.parse(System.getProperty(LOG_LEVEL_PROPERTY_NAME));
		} catch (Exception e) {
		    logger.warn("Exception caught when trying to set log level", e);
		}
	    
	    if (System.getProperty(LOG_FILE_PROPERTY_NAME) != null)
		try {
		    handler = new FileHandler(System.getProperty(LOG_FILE_PROPERTY_NAME));
		} catch (Exception e) {
		    logger.warn("Exception caught when trying to set log file", e);
		}
	}
    }

}
<commit_msg>catching Throwable in main application catch<commit_after>package com.github.mnicky.bible4j;

import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

import org.slf4j.LoggerFactory;

import com.github.mnicky.bible4j.cli.CommandParser;
import com.github.mnicky.bible4j.storage.H2DbBibleStorageFactory;

/**
 * Main class of the application, which starts the application.
 *
 */
public final class AppRunner {
    
    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(AppRunner.AppLogger.class);
    
    /**
     * This class has disabled instantiating
     */
    private AppRunner() {}
    
    /**
     * Main method of the application, collecting commandline Arguments and starting the Application 
     * @param args commandline arguments
     */
    public static void main(String[] args) {

	try {
	    AppLogger.setUpLoggers(Level.OFF, new ConsoleHandler());
	    CommandParser cp = new CommandParser(new H2DbBibleStorageFactory());
	    cp.launch(args);
	} catch (Throwable e) {
	    // for user
	    System.out.println("Error: " + e.getMessage());
	    // for log
	    logger.error("Exception caught", e);
	}

    }

    /**
     * Name of this class is used as Logger name for all classes of this Application and this class is also responsible for setting the Logger level
     * and logging handler.
     *
     */
    public static class AppLogger {
	
	private final static org.slf4j.Logger logger = LoggerFactory.getLogger(AppRunner.AppLogger.class);
	
	private static Level level = null;
	private static Handler handler = null;
	
	private static final String LOG_LEVEL_PROPERTY_NAME = "log.level";
	private static final String LOG_FILE_PROPERTY_NAME = "log.file";

	/**
	 * Sets the default log handler and log level for Logger used in bible4j.
	 * This method also checks for presence of system properties 'log.level',
	 * and 'log.file' and if exists, their value overrides default logging settings.
	 */
	public static void setUpLoggers(Level defaultLevel, Handler defaultHandler) {
	    level = defaultLevel;
	    handler = defaultHandler;
	    getLoggingProperties();
	    
	    //reset logger
	    Logger appLogger = Logger.getLogger(AppRunner.AppLogger.class.getName());
	    LogManager.getLogManager().reset();
	    
	    //set logger settings
	    appLogger.setLevel(level);
	    handler.setLevel(level);
	    appLogger.addHandler(handler);
	    LogManager.getLogManager().addLogger(appLogger);
	}

	private static void getLoggingProperties() {
	    if (System.getProperty(LOG_LEVEL_PROPERTY_NAME) != null)
		try {
		    level = Level.parse(System.getProperty(LOG_LEVEL_PROPERTY_NAME));
		} catch (Exception e) {
		    logger.warn("Exception caught when trying to set log level", e);
		}
	    
	    if (System.getProperty(LOG_FILE_PROPERTY_NAME) != null)
		try {
		    handler = new FileHandler(System.getProperty(LOG_FILE_PROPERTY_NAME));
		} catch (Exception e) {
		    logger.warn("Exception caught when trying to set log file", e);
		}
	}
    }

}

{'fraction_non_alphanumeric': 0.09581410154384848, 'fraction_numerical': 0.002864873468088493, 'mean_word_length': 3.4885714285714284, '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': '932262', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1772, 'n_words': 505}