<commit_before>package com.elsewhere_games.lib.logging;

import com.elsewhere_games.lib.logging.mock.MockAppender;
import org.junit.Assert;
import org.junit.Test;

/**
 * <p>A test case for the {@link LogManager} class.</p>
 */
public class LogManagerTestCase {

	@Test
	public void managerIsASingleton() {
		LogManager instance1 = LogManager.getInstance();
		LogManager instance2 = LogManager.getInstance();

		Assert.assertEquals(instance1, instance2);
	}

	@Test
	public void appendersAreAppliedToExistingLogs() {
		String logName = "new_log";
		Log log = LogManager.getInstance().getLog(logName);
		log.setLevel(Level.DEBUG);

		MockAppender appender = new MockAppender();

		String message = "Test message";
		log.debug(message);

		Assert.assertNull(appender.getLastSource());
		Assert.assertNotEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertFalse(appender.getLastMessage().equals(message));

		LogManager.getInstance().addAppender(appender);

		log.debug(message);

		Assert.assertEquals(log, appender.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertTrue(appender.getLastMessage().equals(message));
	}

	@Test
	public void appendersAreAppliedToNewLogs() {
		MockAppender appender = new MockAppender();
		LogManager.getInstance().addAppender(appender);

		String logName = "new_log";
		Log log = LogManager.getInstance().getLog(logName);

		String message = "Test message";
		log.debug(message);

		Assert.assertEquals(log, appender.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertTrue(appender.getLastMessage().equals(message));<commit_msg>Adds a test to make sure multiple appenders are cached by the log mananger.<commit_after>package com.elsewhere_games.lib.logging;

// JUnit
import org.junit.Assert;
import org.junit.Test;

// Logging Mocks
import com.elsewhere_games.lib.logging.mock.MockAppender;

/**
 * <p>A test case for the {@link LogManager} class.</p>
 */
public class LogManagerTestCase {

	@Test
	public void managerIsASingleton() {
		LogManager instance1 = LogManager.getInstance();
		LogManager instance2 = LogManager.getInstance();

		Assert.assertEquals(instance1, instance2);
	}

	@Test
	public void appendersAreAppliedToExistingLogs() {
		String name = "new_log";
		Log log = LogManager.getInstance().getLog(name);
		log.setLevel(Level.DEBUG);

		MockAppender appender = new MockAppender();

		String message = "Test message";
		log.debug(message);

		Assert.assertNull(appender.getLastSource());
		Assert.assertNotEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertFalse(appender.getLastMessage().equals(message));

		LogManager.getInstance().addAppender(appender);

		log.debug(message);

		Assert.assertEquals(log, appender.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertTrue(appender.getLastMessage().equals(message));
	}

	@Test
	public void appendersAreAppliedToNewLogs() {
		MockAppender appender = new MockAppender();
		LogManager.getInstance().addAppender(appender);

		String name = "new_log";
		Log log = LogManager.getInstance().getLog(name);
		log.setLevel(Level.DEBUG);

		String message = "Test message";
		log.debug(message);

		Assert.assertEquals(log, appender.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender.getLastLevel());
		Assert.assertTrue(appender.getLastMessage().equals(message));
	}

	@Test
	public void multipleAppendersAreAppliedToNewLogs() {
		MockAppender appender1 = new MockAppender();
		LogManager.getInstance().addAppender(appender1);

		MockAppender appender2 = new MockAppender();
		LogManager.getInstance().addAppender(appender2);

		String name = "new_log";
		Log log = LogManager.getInstance().getLog(name);
		log.setLevel(Level.DEBUG);

		String message = "Test message";
		log.debug(message);

		Assert.assertEquals(log, appender1.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender1.getLastLevel());
		Assert.assertTrue(appender1.getLastMessage().equals(message));

		Assert.assertEquals(log, appender2.getLastSource());
		Assert.assertEquals(Level.DEBUG, appender2.getLastLevel());
		Assert.assertTrue(appender2.getLastMessage().equals(message));
{'fraction_non_alphanumeric': 0.12981455064194009, 'fraction_numerical': 0.0042796005706134095, 'mean_word_length': 5.862969004893964, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1566205', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1259, 'n_words': 226}