<commit_before>package zutil.log;

import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Utility functions for the standard Java Logger
 * 
 * @author Ziver
 */
public class LogUtil {
	private LogUtil(){}

	/**
	 * @return a new Logger for the calling class
	 */
	public static Logger getLogger(){
		return Logger.getLogger(getCalingClass());
	}

	/**
	 * @return the parent class other than Logger in the stack
	 */
	public static String getCalingClass(){
		StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
		for(int i=1; i<stackTraceElements.length ;++i){
			String name = stackTraceElements[i].getClassName();
			//name = name.substring( name.lastIndexOf('.')+1 );
			if( !name.equals( LogUtil.class.getName() ) ){
				//System.out.println("\""+name+"\"");
				return name;
			}
		}
		return null;
	}

	/**
	 * Sets the global log formatter to the specified one
	 * 
	 * @param f is the formatter class
	 */
	public static void setGlobalFormatter(Formatter f){
		Logger root = Logger.getLogger("");
		for (Handler handler : root.getHandlers()) {
			handler.setFormatter(f);
		}
	}

	/**
	 * Sets the global log level
	 */
	public static void setGlobalLevel(Level level){
		setLevel("", level);
	}

	/**
	 * Sets the log level for a specified class
	 */
	public static void setLevel(Class<?> c, Level level){
		setLevel(c.getName(), level);
	}

	/**
	 * Sets the log level for a specified logger
	 */
	public static void setLevel(String name, Level level){
		Logger logger = Logger.getLogger(name);
		logger.setLevel(level);<commit_msg>added a logger to the Util class<commit_after>package zutil.log;

import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Utility functions for the standard Java Logger
 * 
 * @author Ziver
 */
public class LogUtil {
	private static final Logger logger = Logger.getLogger( LogUtil.class.getName() );
	
	private LogUtil(){}

	/**
	 * @return a new Logger for the calling class
	 */
	public static Logger getLogger(){
		return Logger.getLogger(getCalingClass());
	}

	/**
	 * @return the parent class other than Logger in the stack
	 */
	public static String getCalingClass(){
		StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
		for(int i=1; i<stackTraceElements.length ;++i){
			String name = stackTraceElements[i].getClassName();
			//name = name.substring( name.lastIndexOf('.')+1 );
			if( !name.equals( LogUtil.class.getName() ) ){
				//System.out.println("\""+name+"\"");
				logger.fine("Caling class: \""+name+"\"");
				return name;
			}
		}
		return null;
	}

	/**
	 * Sets the global log formatter to the specified one
	 * 
	 * @param f is the formatter class
	 */
	public static void setGlobalFormatter(Formatter f){
		Logger root = Logger.getLogger("");
		for (Handler handler : root.getHandlers()) {
			handler.setFormatter(f);
		}
	}

	/**
	 * Sets the global log level
	 */
	public static void setGlobalLevel(Level level){
		setLevel("", level);
	}

	/**
	 * Sets the log level for a specified class
	 */
	public static void setLevel(Class<?> c, Level level){
		setLevel(c.getName(), level);
	}

	/**
	 * Sets the log level for a specified logger
	 */
	public static void setLevel(String name, Level level){
		logger.fine("Changing log level of \""+name+"\" to \""+level.getLocalizedName()+"\"");
		Logger logger = Logger.getLogger(name);
		logger.setLevel(level);
{'fraction_non_alphanumeric': 0.13873626373626374, 'fraction_numerical': 0.001098901098901099, 'mean_word_length': 3.7971014492753623, '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': '6688862', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1079, 'n_words': 324}