<commit_before>package io.github.jython234.nectar.server;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Represents the server's internal event log that records
 * all actions performed by management sessions and clients.
 *
 * @author jython234
 */
public class EventLog {
    @Getter private final List<Entry> entries = new ArrayList<>();

    public void addEntry(Entry entry) {
        synchronized (entries) {
            this.entries.add(entry);
        }
    }

    public void addEntry(EntryLevel level, String message) {
        synchronized (entries) {
            this.entries.add(new Entry(LocalDateTime.now(), level, message));
        }
    }

    public void logEntry(EntryLevel level, String message) {
        switch (level) {
            case DEBUG:
                NectarServerApplication.getLogger().debug("!|! " + message);
                break;
            case INFO:
                NectarServerApplication.getLogger().info("!|! " + message);
                break;
            case NOTICE:
                NectarServerApplication.getLogger().info("!|! (NOTICE): " + message);
                break;
            case WARNING:
                NectarServerApplication.getLogger().warn("!|! " + message);
                break;
            case ERROR:
                NectarServerApplication.getLogger().error("!|! " + message);
                break;
        }

        this.addEntry(new Entry(LocalDateTime.now(), level, message));
    }

    /**<commit_msg>EventLog will use it's own Logger instead of the "Nectar" one<commit_after>package io.github.jython234.nectar.server;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Represents the server's internal event log that records
 * all actions performed by management sessions and clients.
 *
 * @author jython234
 */
public class EventLog {
    @Getter private final List<Entry> entries = new ArrayList<>();
    @Getter private final Logger eventLogLogger;

    public EventLog() {
        this.eventLogLogger = LoggerFactory.getLogger("Nectar-EventLog");
    }

    public void addEntry(Entry entry) {
        synchronized (entries) {
            this.entries.add(entry);
        }
    }

    public void addEntry(EntryLevel level, String message) {
        synchronized (entries) {
            this.entries.add(new Entry(LocalDateTime.now(), level, message));
        }
    }

    public void logEntry(EntryLevel level, String message) {
        switch (level) {
            case DEBUG:
                this.eventLogLogger.debug("!|! " + message);
                break;
            case INFO:
                this.eventLogLogger.info("!|! " + message);
                break;
            case NOTICE:
                this.eventLogLogger.info("!|! (NOTICE): " + message);
                break;
            case WARNING:
                this.eventLogLogger.warn("!|! " + message);
                break;
            case ERROR:
                this.eventLogLogger.error("!|! " + message);
                break;
        }

        this.addEntry(new Entry(LocalDateTime.now(), level, message));
    }

    /**
{'fraction_non_alphanumeric': 0.11028315946348734, 'fraction_numerical': 0.004172876304023845, 'mean_word_length': 2.151173708920188, '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': '3107753', 'n_tokens_mistral': 929, 'n_tokens_neox': 899, 'n_words': 217}