25class Logger :
public std::enable_shared_from_this<Logger> {
26 LLAPI
void printStr(LogLevel, std::string&&)
const noexcept;
32 std::unique_ptr<Impl> impl;
35 explicit PrivateTag() =
default;
39 template <
typename... Args>
40 void log(LogLevel level, fmt::format_string<Args...> fmt, Args&&... args)
const {
41 if (shouldLog(level)) printStr(level, fmt::vformat(fmt.get(), fmt::make_format_args(args...)));
43 void log(LogLevel level, std::string&& msg)
const {
44 if (shouldLog(level)) printStr(level, std::move(msg));
46 template <ll::concepts::IsString S>
47 void log(LogLevel level, S
const& msg)
const {
48 if (shouldLog(level)) printStr(level, std::string{msg});
51 template <
typename... Args>
52 void fatal(fmt::format_string<Args...> fmt, Args&&... args)
const {
53 log(LogLevel::Fatal, fmt, std::forward<Args>(args)...);
55 void fatal(std::string&& msg)
const { log(LogLevel::Fatal, std::move(msg)); }
56 template <ll::concepts::IsString S>
57 void fatal(S
const& msg)
const {
58 log(LogLevel::Fatal, msg);
61 template <
typename... Args>
62 void error(fmt::format_string<Args...> fmt, Args&&... args)
const {
63 log(LogLevel::Error, fmt, std::forward<Args>(args)...);
65 void error(std::string&& msg)
const { log(LogLevel::Error, std::move(msg)); }
66 template <ll::concepts::IsString S>
67 void error(S
const& msg)
const {
68 log(LogLevel::Error, msg);
71 template <
typename... Args>
72 void warn(fmt::format_string<Args...> fmt, Args&&... args)
const {
73 log(LogLevel::Warn, fmt, std::forward<Args>(args)...);
75 void warn(std::string&& msg)
const { log(LogLevel::Warn, std::move(msg)); }
76 template <ll::concepts::IsString S>
77 void warn(S
const& msg)
const {
78 log(LogLevel::Warn, msg);
81 template <
typename... Args>
82 void info(fmt::format_string<Args...> fmt, Args&&... args)
const {
83 log(LogLevel::Info, fmt, std::forward<Args>(args)...);
85 void info(std::string&& msg)
const { log(LogLevel::Info, std::move(msg)); }
86 template <ll::concepts::IsString S>
87 void info(S
const& msg)
const {
88 log(LogLevel::Info, msg);
91 template <
typename... Args>
92 void debug(fmt::format_string<Args...> fmt, Args&&... args)
const {
93 log(LogLevel::Debug, fmt, std::forward<Args>(args)...);
95 void debug(std::string&& msg)
const { log(LogLevel::Debug, std::move(msg)); }
96 template <ll::concepts::IsString S>
97 void debug(S
const& msg)
const {
98 log(LogLevel::Debug, msg);
101 template <
typename... Args>
102 void trace(fmt::format_string<Args...> fmt, Args&&... args)
const {
103 log(LogLevel::Trace, fmt, std::forward<Args>(args)...);
105 void trace(std::string&& msg)
const { log(LogLevel::Trace, std::move(msg)); }
106 template <ll::concepts::IsString S>
107 void trace(S
const& msg)
const {
108 log(LogLevel::Trace, msg);
113 explicit Logger(PrivateTag, std::string_view);
115 LLNDAPI std::string
const& getTitle()
const noexcept;
117 LLNDAPI LogLevel getLevel()
const noexcept;
119 LLNDAPI
bool shouldLog(LogLevel level)
const noexcept;
121 LLAPI
void setLevel(LogLevel level);
123 LLAPI
void setFlushLevel(LogLevel level);
127 LLAPI
void flush()
const;
129 LLAPI
void clearSink()
const;
131 LLAPI
size_t addSink(std::shared_ptr<SinkBase> sink)
const;
133 LLAPI std::shared_ptr<SinkBase> getSink(
size_t index)
const;