#pragma once #include #include #include #include #include #include #include #include namespace Void::Logging { class MultiLogger; } // namespace Void::Logging namespace Echoion::Core { // ILogger implementation backed by the Void::Logging framework. // // Output is produced by a Void MultiLogger fanning out to: // * a ConsoleLogger (stdout), // * a SplitFileLogger writing per-level files (/.log) plus a // combined /all.log, each rolling independently by size, and // * a CallbackLogger bridging back to the registered ILogger callbacks. // The ILogger surface (levels, callbacks, console/file toggles, rotation // knobs) is preserved so existing call sites and the ECHOION_LOG_* macros // keep working unchanged. class Logger : public Api::ILogger { public: explicit Logger(std::string_view logDir = "logs", std::string_view baseName = "echoion"); ~Logger() override; void log(Api::LogLevel level, std::string_view message, std::source_location location) override; void setMinLevel(Api::LogLevel level) override; [[nodiscard]] Api::LogLevel getMinLevel() const override; void registerCallback(const LogCallback& callback) override; void unregisterCallback(const LogCallback& callback) override; void flush(); void setConsoleOutput(bool enabled); void setFileOutput(bool enabled); void setMaxFileSize(uint64_t bytes); void setMaxFiles(uint32_t count); private: // (Re)assemble the Void sink tree from the current toggles/limits. void rebuildSinks(); // Fan a Void log entry out to the registered ILogger callbacks. void dispatchToCallbacks(Api::LogLevel level, const std::string& message, const std::string& file, uint32_t line, const std::string& function); std::filesystem::path logDir_; std::string baseName_; std::shared_ptr sink_; std::mutex sinkMutex_; std::atomic minLevel_{Api::LogLevel::Info}; std::atomic consoleOutput_{true}; std::atomic fileOutput_{true}; std::atomic maxFileSize_{10 * 1024 * 1024}; // 10 MB std::atomic maxFiles_{5}; std::vector callbacks_; std::mutex callbackMutex_; }; } // namespace Echoion::Core