<commit_before>package alma.acs.logging;

import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

import alma.acs.logging.config.LogConfig;
import alma.acs.logging.formatters.AcsXMLLogFormatter;

/**
 * An <code>AcsLogger</code> that prints to stdout the XML messages that normally
 * would be sent to the remote Log service.
 * <p>
 * The purpose of this class is to allow testing AcsLogger functionality
 * without the need for a running ACS infrastructure, which would typically be accessed using 
 * the class ComponentClient that only builds in a later module (jcont).
 *  
 * @author hsommer
 */
public class LocalOnlyAcsLogger extends AcsLogger {

	private static LocalOnlyAcsLogger instance;
	
	private LocalOnlyAcsLogger(String namespace, LogConfig testLogConfig) {
		super(namespace, null, new LogConfig());
		addLoggerClass(LocalOnlyAcsLogger.class); 
	}

	public static synchronized LocalOnlyAcsLogger getInstance(String namespace, Level level) {
		if (instance == null) {
			LogConfig testLogConfig = new LogConfig();
			testLogConfig.setDefaultMinLogLevelLocal(AcsLogLevel.getNativeLevel(level).getAcsLevel());
			instance = new LocalOnlyAcsLogger(namespace, testLogConfig);
			instance.setUseParentHandlers(false);
			Handler logHandler = new StdOutConsoleHandler(testLogConfig, namespace);
			logHandler.setFormatter(new AcsXMLLogFormatter() {
				public String format(LogRecord lr) {
					String xml = super.format(lr);
					return xml + '\n';<commit_msg>bugfix: now actually uses the LogConfig passed in the ctor<commit_after>package alma.acs.logging;

import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

import alma.acs.logging.config.LogConfig;
import alma.acs.logging.formatters.AcsXMLLogFormatter;

/**
 * An <code>AcsLogger</code> that prints to stdout the XML messages that normally
 * would be sent to the remote Log service.
 * <p>
 * The purpose of this class is to allow testing AcsLogger functionality
 * without the need for a running ACS infrastructure, which would typically be accessed using 
 * the class ComponentClient that only builds in a later module (jcont).
 *  
 * @author hsommer
 */
public class LocalOnlyAcsLogger extends AcsLogger {

	private static LocalOnlyAcsLogger instance;
	
	private LocalOnlyAcsLogger(String namespace, LogConfig testLogConfig) {
		super(namespace, null, testLogConfig);
		addLoggerClass(LocalOnlyAcsLogger.class); 
	}

	public static synchronized LocalOnlyAcsLogger getInstance(String namespace, Level level) {
		if (instance == null) {
			LogConfig testLogConfig = new LogConfig();
			testLogConfig.setDefaultMinLogLevelLocal(AcsLogLevel.getNativeLevel(level).getAcsLevel());
			instance = new LocalOnlyAcsLogger(namespace, testLogConfig);
			instance.setUseParentHandlers(false);
			Handler logHandler = new StdOutConsoleHandler(testLogConfig, namespace);
			logHandler.setFormatter(new AcsXMLLogFormatter() {
				public String format(LogRecord lr) {
					String xml = super.format(lr);
					return xml + '\n';
{'fraction_non_alphanumeric': 0.08211619604024667, 'fraction_numerical': 0.0, 'mean_word_length': 5.226262626262626, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6818116', 'n_tokens_mistral': 920, 'n_tokens_neox': 857, 'n_words': 261}