Files
VoidLoaderApi/include/Logging/LoggerManager.hpp
T
faumaray 053d1b7168 Logger api
Signed-off-by: Faumaray <faumaray@gmail.com>
2025-10-19 23:00:07 +03:00

38 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <Logging/Provider.hpp>
#include <atomic>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
namespace vl::logging {
class LoggerManager {
public:
static LoggerManager& instance(); // Meyers singleton
// Called by VoidLoaderCore once it’s ready
void setProvider(Provider* p);
// Throws (E1) if provider not set yet
Provider& provider() const;
// Convenience forwarding for mods
std::shared_ptr<Logger> get(std::string_view prefix) const;
std::shared_ptr<Logger> createConsole(std::string prefix, Level lvl = Level::Info) const;
std::shared_ptr<Logger> createFile(std::string prefix, std::string basePath,
std::uintmax_t maxBytes = 0, Level lvl = Level::Info) const;
std::shared_ptr<Logger> createCombined(std::string prefix, std::string basePath,
std::uintmax_t maxBytes = 0, Level lvl = Level::Info) const;
private:
LoggerManager() = default;
LoggerManager(const LoggerManager&) = delete;
LoggerManager& operator=(const LoggerManager&) = delete;
std::atomic<Provider*> provider_{nullptr};
};
} // namespace vl::log