Files
VoidLoaderCore/include/Logging/LoggerProvider.hpp
T
faumaray de538e00b6
VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit
Logger api
Signed-off-by: Faumaray <faumaray@gmail.com>
2025-10-19 23:18:07 +03:00

30 lines
1.0 KiB
C++

#pragma once
#include <Logging/Provider.hpp>
#include <Logging/Sink.hpp>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>
namespace vl::logging {
class LoggerProvider final : public Provider {
public:
std::shared_ptr<Logger> createConsole(std::string prefix, Level lvl) override;
std::shared_ptr<Logger> createFile(std::string prefix, std::string basePath,
std::uintmax_t maxBytes, Level lvl) override;
std::shared_ptr<Logger> createCombined(std::string prefix, std::string basePath,
std::uintmax_t maxBytes, Level lvl) override;
std::shared_ptr<Logger> get(std::string_view prefix) const override;
bool exists(std::string_view prefix) const override;
private:
std::shared_ptr<Logger> emplaceOrGet_(std::string prefix, std::shared_ptr<Sink> sink, Level lvl);
mutable std::mutex mtx_;
std::unordered_map<std::string, std::shared_ptr<Logger>> byPrefix_;
};
} // namespace vl::log