<commit_before>#pragma once

#include <memory>
#include <string>
#include <set>
#include <string>

#include <lug/System/Debug.hpp>
#include <lug/System/Export.hpp>
#include <lug/System/Logger/Common.hpp>
#include <lug/System/Logger/Formatter.hpp>
#include <lug/System/Logger/Handler.hpp>
#include <lug/System/Logger/LoggingFacility.hpp>
#include <lug/System/Logger/Message.hpp>
#include <lug/System/SourceInfo.hpp>
#include <lug/System/Utils.hpp>

namespace lug {
namespace System {

class LUG_SYSTEM_API Logger {
public:
    Logger(const std::string& loggerName);
    virtual ~Logger() {}

    virtual void addHandler(Handler* handler) {
        _handlers.insert(handler);
    }

    virtual void addHandler(const std::string& name) {
        _handlers.insert(LoggingFacility::getHandler(name));
    }

    virtual void defaultErrHandler(const std::string& msg) {
        // TODO: Handle error
        (void)msg;
    }

    template<typename T>
    inline void log(Level::enumLevel lvl, const T& msg) {
        try {
            priv::Message logMsg(_name, lvl);
            logMsg.raw.write("{}", msg);
            handle(logMsg);
        }
        catch (const std::exception& ex) {<commit_msg>Added error handler<commit_after>#pragma once

#include <memory>
#include <string>
#include <set>
#include <string>

#include <lug/System/Debug.hpp>
#include <lug/System/Export.hpp>
#include <lug/System/Logger/Common.hpp>
#include <lug/System/Logger/Formatter.hpp>
#include <lug/System/Logger/Handler.hpp>
#include <lug/System/Logger/LoggingFacility.hpp>
#include <lug/System/Logger/Message.hpp>
#include <lug/System/SourceInfo.hpp>
#include <lug/System/Utils.hpp>

namespace lug {
namespace System {

class LUG_SYSTEM_API Logger {
public:
    Logger(const std::string& loggerName);
    virtual ~Logger() {}

    virtual void addHandler(Handler* handler) {
        _handlers.insert(handler);
    }

    virtual void addHandler(const std::string& name) {
        _handlers.insert(LoggingFacility::getHandler(name));
    }

    virtual void defaultErrHandler(const std::string& msg) {
        log(Level::Fatal, "Exception in logger {}: {}", _name, msg);
    }

    template<typename T>
    inline void log(Level::enumLevel lvl, const T& msg) {
        try {
            priv::Message logMsg(_name, lvl);
            logMsg.raw.write("{}", msg);
            handle(logMsg);
        }
        catch (const std::exception& ex) {
{'fraction_non_alphanumeric': 0.1384297520661157, 'fraction_numerical': 0.0, 'mean_word_length': 3.4667896678966788, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '790757', 'n_tokens_mistral': 782, 'n_tokens_neox': 773, 'n_words': 166}