diff --git a/include/echoion/api.hpp b/include/echoion/api.hpp index 11bfd64..4df75d0 100644 --- a/include/echoion/api.hpp +++ b/include/echoion/api.hpp @@ -9,7 +9,6 @@ // Granular type modules #include "api/audio/AudioTypes.hpp" #include "api/config/ConfigTypes.hpp" -#include "api/logger/LoggerInterface.hpp" #include "api/network/NetworkInterface.hpp" #include "api/network/NetworkTypes.hpp" #include "api/plugin/PluginTypes.hpp" diff --git a/include/echoion/api/logger/LoggerInterface.hpp b/include/echoion/api/logger/LoggerInterface.hpp deleted file mode 100644 index 3ea100e..0000000 --- a/include/echoion/api/logger/LoggerInterface.hpp +++ /dev/null @@ -1,166 +0,0 @@ -#pragma once - -#include "Types.hpp" -#include -#include -#include -#include -#include - -namespace Echoion::Api -{ - - // Logger interface for the user's custom logger implementation - class ILogger - { - public: - - virtual ~ILogger() = default; - - // Core logging method - virtual void log(LogLevel level, std::string_view message, - std::source_location location = - std::source_location::current()) = 0; - - // Convenience methods - virtual void debug( - std::string_view message, - std::source_location location = std::source_location::current()) - { - log(LogLevel::Debug, message, location); - } - - virtual void info( - std::string_view message, - std::source_location location = std::source_location::current()) - { - log(LogLevel::Info, message, location); - } - - virtual void warning( - std::string_view message, - std::source_location location = std::source_location::current()) - { - log(LogLevel::Warning, message, location); - } - - virtual void error( - std::string_view message, - std::source_location location = std::source_location::current()) - { - log(LogLevel::Error, message, location); - } - - virtual void critical( - std::string_view message, - std::source_location location = std::source_location::current()) - { - log(LogLevel::Critical, message, location); - } - - // Template method for formatted logging - template - void logf( - LogLevel level, std::format_string fmt, Args&&... args, - std::source_location location = std::source_location::current()) - { - log(level, std::format(fmt, std::forward(args)...), - location); - } - - // Set minimum log level - virtual void setMinLevel(LogLevel level) = 0; - [[nodiscard]] virtual LogLevel getMinLevel() const = 0; - - // Register log callback - using LogCallback = std::function; - virtual void registerCallback(const LogCallback& callback) = 0; - virtual void unregisterCallback(const LogCallback& callback) = 0; - }; - - using LoggerPtr = std::shared_ptr; - - // Global logger accessor - class LoggerRegistry - { - public: - - static LoggerRegistry& instance() - { - static LoggerRegistry instance; - return instance; - } - - void setLogger(LoggerPtr logger) { logger_ = std::move(logger); } - [[nodiscard]] LoggerPtr getLogger() const { return logger_; } - - [[nodiscard]] bool hasLogger() const noexcept - { - return static_cast(logger_); - } - - private: - - LoggerRegistry() = default; - LoggerPtr logger_; - }; - -// Convenience macros -#define ECHOION_LOG_DEBUG(msg) \ - do { \ - if (auto logger = \ - Echoion::Api::LoggerRegistry::instance().getLogger(); \ - logger) { \ - logger->debug(msg); \ - } else { \ - std::cout << "[DEBUG] Echoion: " << std::string(msg) << std::endl; \ - } \ - } while (0) - -#define ECHOION_LOG_INFO(msg) \ - do { \ - if (auto logger = \ - Echoion::Api::LoggerRegistry::instance().getLogger(); \ - logger) { \ - logger->info(msg); \ - } else { \ - std::cout << "[INFO] Echoion: " << std::string(msg) << std::endl; \ - } \ - } while (0) - -#define ECHOION_LOG_WARNING(msg) \ - do { \ - if (auto logger = \ - Echoion::Api::LoggerRegistry::instance().getLogger(); \ - logger) { \ - logger->warning(msg); \ - } else { \ - std::cout << "[WARNING] Echoion: " << std::string(msg) \ - << std::endl; \ - } \ - } while (0) - -#define ECHOION_LOG_ERROR(msg) \ - do { \ - if (auto logger = \ - Echoion::Api::LoggerRegistry::instance().getLogger(); \ - logger) { \ - logger->error(msg); \ - } else { \ - std::cerr << "[ERROR] Echoion: " << std::string(msg) << std::endl; \ - } \ - } while (0) - -#define ECHOION_LOG_CRITICAL(msg) \ - do { \ - if (auto logger = \ - Echoion::Api::LoggerRegistry::instance().getLogger(); \ - logger) { \ - logger->critical(msg); \ - } else { \ - std::cerr << "[CRITICAL] Echoion: " << std::string(msg) \ - << std::endl; \ - } \ - } while (0) - -} // namespace Echoion::Api