29class Logger :
public std::enable_shared_from_this<Logger> {
30 LLAPI
void printStr(LogLevel, std::string&&)
const noexcept;
36 std::unique_ptr<Impl> impl;
39 explicit PrivateTag() =
default;
43 template <
typename... Args>
44 void log(LogLevel level, fmt::format_string<Args...> fmt, Args&&... args)
const {
45 if (shouldLog(level)) printStr(level, fmt::vformat(fmt.get(), fmt::make_format_args(args...)));
47 void log(LogLevel level, std::string&& msg)
const {
48 if (shouldLog(level)) printStr(level, std::move(msg));
50 template <ll::concepts::IsString S>
51 void log(LogLevel level, S
const& msg)
const {
52 if (shouldLog(level)) printStr(level, std::string{msg});
55 template <
typename... Args>
56 void fatal(fmt::format_string<Args...> fmt, Args&&... args)
const {
57 log(LogLevel::Fatal, fmt, std::forward<Args>(args)...);
59 void fatal(std::string&& msg)
const { log(LogLevel::Fatal, std::move(msg)); }
60 template <ll::concepts::IsString S>
61 void fatal(S
const& msg)
const {
62 log(LogLevel::Fatal, msg);
65 template <
typename... Args>
66 void error(fmt::format_string<Args...> fmt, Args&&... args)
const {
67 log(LogLevel::Error, fmt, std::forward<Args>(args)...);
69 void error(std::string&& msg)
const { log(LogLevel::Error, std::move(msg)); }
70 template <ll::concepts::IsString S>
71 void error(S
const& msg)
const {
72 log(LogLevel::Error, msg);
75 template <
typename... Args>
76 void warn(fmt::format_string<Args...> fmt, Args&&... args)
const {
77 log(LogLevel::Warn, fmt, std::forward<Args>(args)...);
79 void warn(std::string&& msg)
const { log(LogLevel::Warn, std::move(msg)); }
80 template <ll::concepts::IsString S>
81 void warn(S
const& msg)
const {
82 log(LogLevel::Warn, msg);
85 template <
typename... Args>
86 void info(fmt::format_string<Args...> fmt, Args&&... args)
const {
87 log(LogLevel::Info, fmt, std::forward<Args>(args)...);
89 void info(std::string&& msg)
const { log(LogLevel::Info, std::move(msg)); }
90 template <ll::concepts::IsString S>
91 void info(S
const& msg)
const {
92 log(LogLevel::Info, msg);
95 template <
typename... Args>
96 void debug(fmt::format_string<Args...> fmt, Args&&... args)
const {
97 log(LogLevel::Debug, fmt, std::forward<Args>(args)...);
99 void debug(std::string&& msg)
const { log(LogLevel::Debug, std::move(msg)); }
100 template <ll::concepts::IsString S>
101 void debug(S
const& msg)
const {
102 log(LogLevel::Debug, msg);
105 template <
typename... Args>
106 void trace(fmt::format_string<Args...> fmt, Args&&... args)
const {
107 log(LogLevel::Trace, fmt, std::forward<Args>(args)...);
109 void trace(std::string&& msg)
const { log(LogLevel::Trace, std::move(msg)); }
110 template <ll::concepts::IsString S>
111 void trace(S
const& msg)
const {
112 log(LogLevel::Trace, msg);
117 explicit Logger(PrivateTag, std::string_view);
119 LLNDAPI std::string
const& getTitle()
const noexcept;
121 LLNDAPI LogLevel getLevel()
const noexcept;
123 LLNDAPI
bool shouldLog(LogLevel level)
const noexcept;
125 LLAPI
void setLevel(LogLevel level);
127 LLAPI
void setFlushLevel(LogLevel level);
131 LLAPI
void flush()
const;
133 LLAPI
void clearSink()
const;
135 LLAPI
size_t addSink(std::shared_ptr<SinkBase> sink)
const;
137 LLAPI std::shared_ptr<SinkBase> getSink(
size_t index)
const;