#pragma once #include #include #include #include "LogChannel.h" #include "LogLevel.h" namespace L2Bot::Domain::Logger { class Logger { public: Logger(std::vector> channels) : m_Channels(std::move(channels)) {}; virtual ~Logger() = default; template void Error(const std::wformat_string format, Args... args) const { Log(LogLevel::error, format, args...); } template void Warning(const std::wformat_string format, Args... args) const { Log(LogLevel::warning, format, args...); } template void Info(const std::wformat_string format, Args... args) const { Log(LogLevel::info, format, args...); } template void App(const std::wformat_string format, Args... args) const { Log(LogLevel::app, format, args...); } void Error(const std::wstring& message) const { Log(LogLevel::error, message); } void Warning(const std::wstring& message) const { Log(LogLevel::warning, message); } void Info(const std::wstring& message) const { Log(LogLevel::info, message); } void App(const std::wstring& message) const { Log(LogLevel::app, message); } private: template void Log(LogLevel level, const std::wformat_string format, Args... args) const { Log(level, std::vformat(format.get(), std::make_wformat_args(args...))); } void Log(LogLevel level, const std::wstring& message) const { std::wstring prefix = L""; if (level == LogLevel::error) { prefix = L"[Error]: "; } else if (level == LogLevel::warning) { prefix = L"[Warning]: "; } else if (level == LogLevel::info) { prefix = L"[Info]: "; } else if (level == LogLevel::app) { prefix = L"[App]: "; } for (const auto& channel : m_Channels) { if (channel->IsAppropriateLevel(level)) { channel->SendToChannel(prefix + message); } } } private: const std::vector> m_Channels; }; }