<commit_before>package com.orientechnologies.common.log;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.orientechnologies.common.exception.OException;

public class OLogManager {

	private static final String				SYSPROPERTY_LOG_LEVEL	= "orient.log.level";

	private Level											level;
	private boolean										warn									= true;
	private boolean										info									= true;
	private boolean										debug									= true;
	private boolean										error									= true;

	private static final OLogManager	instance							= new OLogManager();
	private static final DateFormat		dateFormat						= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS");

	public OLogManager() {
		if (System.getProperty(SYSPROPERTY_LOG_LEVEL) != null)
			setLevel(System.getProperty(SYSPROPERTY_LOG_LEVEL));
	}

	public void setLevel(final String iLevel) {
		level = iLevel != null ? Level.parse(iLevel.toUpperCase()) : Level.INFO;
		if (level.equals(Level.FINER) || level.equals(Level.FINE) || level.equals(Level.FINEST))
			debug = info = warn = true;
		else if (level.equals(Level.INFO))
			info = warn = true;
		else if (level.equals(Level.WARNING))
			warn = true;
		else if (level.equals(Level.SEVERE))
			error = true;
	}

	public void log(final Object iRequester, final Level iLevel, final String iMessage, final Throwable iException,
			final Object... iAdditionalArgs) {
		if (iMessage == null)
			return;

		final Logger log = Logger.getLogger(iRequester.getClass().getName());

		// if (!log.isLoggable(iLevel))
		// return;

		final StringBuilder buffer = new StringBuilder();
		buffer.append('\n');
		buffer.append(dateFormat.format(new Date()));
		buffer.append(' ');
		buffer.append(iLevel.getName().substring(0, 4));
		if (iRequester != null) {
			buffer.append(" [");
			buffer.append(iRequester.getClass().getSimpleName());
			buffer.append("]");
		}
		buffer.append(' ');

		// FORMAT THE MESSAGE
		try {
			buffer.append(String.format(iMessage, iAdditionalArgs));
		} catch (Exception e) {
			buffer.append(iMessage);
		}

		if (iException != null)
			log.log(iLevel, buffer.toString(), iException);
		else
			log.log(iLevel, buffer.toString());
	}
<commit_msg>fixed issue on log without requester (console)<commit_after>package com.orientechnologies.common.log;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.orientechnologies.common.exception.OException;

public class OLogManager {

	private static final String				SYSPROPERTY_LOG_LEVEL	= "orient.log.level";

	private Level											level;
	private boolean										warn									= true;
	private boolean										info									= true;
	private boolean										debug									= true;
	private boolean										error									= true;

	private static final OLogManager	instance							= new OLogManager();
	private static final DateFormat		dateFormat						= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS");

	public OLogManager() {
		if (System.getProperty(SYSPROPERTY_LOG_LEVEL) != null)
			setLevel(System.getProperty(SYSPROPERTY_LOG_LEVEL));
	}

	public void setLevel(final String iLevel) {
		level = iLevel != null ? Level.parse(iLevel.toUpperCase()) : Level.INFO;
		if (level.equals(Level.FINER) || level.equals(Level.FINE) || level.equals(Level.FINEST))
			debug = info = warn = true;
		else if (level.equals(Level.INFO))
			info = warn = true;
		else if (level.equals(Level.WARNING))
			warn = true;
		else if (level.equals(Level.SEVERE))
			error = true;
	}

	public void log(final Object iRequester, final Level iLevel, final String iMessage, final Throwable iException,
			final Object... iAdditionalArgs) {
		if (iMessage == null)
			return;

		final Logger log = iRequester != null ? Logger.getLogger(iRequester.getClass().getName()) : Logger.getAnonymousLogger();

		// if (!log.isLoggable(iLevel))
		// return;

		final StringBuilder buffer = new StringBuilder();
		buffer.append('\n');
		buffer.append(dateFormat.format(new Date()));
		buffer.append(' ');
		buffer.append(iLevel.getName().substring(0, 4));
		if (iRequester != null) {
			buffer.append(" [");
			buffer.append(iRequester.getClass().getSimpleName());
			buffer.append("]");
		}
		buffer.append(' ');

		// FORMAT THE MESSAGE
		try {
			buffer.append(String.format(iMessage, iAdditionalArgs));
		} catch (Exception e) {
			buffer.append(iMessage);
		}

		if (iException != null)
			log.log(iLevel, buffer.toString(), iException);
		else
			log.log(iLevel, buffer.toString());
	}

{'fraction_non_alphanumeric': 0.12660588479071694, 'fraction_numerical': 0.0008288437629506838, 'mean_word_length': 3.7416502946954813, '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': '830750', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1524, 'n_words': 341}