89 LogClass log_class = LogClass::kLog,
90 const utils::impl::SourceLocation& location = utils::impl::SourceLocation::Current()
99 const LoggerPtr& logger,
101 LogClass log_class = LogClass::kLog,
102 const
utils::impl::SourceLocation& location =
utils::impl::SourceLocation::Current()
113 LogHelper& AsLvalue() noexcept {
return *
this; }
116 template <
typename... Args>
117 USERVER_IMPL_NODEBUG_INLINE_FUNC
LogHelper& AsLvalue(fmt::format_string<Args...>
fmt, Args&&... args)
noexcept {
118 const fmt::string_view fmt_string =
119#if FMT_VERSION >= 120200
122 static_cast<fmt::string_view
>(
fmt);
124 VFormat(fmt_string, fmt::make_format_args(args...));
129 bool IsLimitReached() const noexcept;
131 template <typename T>
132 USERVER_IMPL_NODEBUG_INLINE_FUNC
LogHelper& operator<<(const T& value) {
133 if constexpr (std::is_constructible_v<std::string_view, T>) {
135 *
this << std::string_view{value};
136 }
else if constexpr (std::is_signed_v<T>) {
137 using LongLong =
long long;
138 *
this << LongLong{value};
139 }
else if constexpr (std::is_unsigned_v<T>) {
140 using UnsignedLongLong =
unsigned long long;
141 *
this << UnsignedLongLong{value};
142 }
else if constexpr (std::is_base_of_v<std::exception, T>) {
143 *this << static_cast<const std::exception&>(value);
144 }
else if constexpr (meta::IsOstreamWritable<T>) {
148 }
else if constexpr (meta::IsRange<T> && !formats::common::IsFormatValue<T>) {
152 VFormat(
"{}", fmt::make_format_args(value));
158 LogHelper& operator<<(
char value)
noexcept;
159 LogHelper& operator<<(std::string_view value)
noexcept;
160 LogHelper& operator<<(
float value)
noexcept;
161 LogHelper& operator<<(
double value)
noexcept;
162 LogHelper& operator<<(
long double value)
noexcept;
163 LogHelper& operator<<(
unsigned long long value)
noexcept;
164 LogHelper& operator<<(
long long value)
noexcept;
165 LogHelper& operator<<(
bool value)
noexcept;
166 LogHelper& operator<<(
const std::exception& value)
noexcept;
181 LogHelper& PutSwTag(std::string_view key, std::string_view value)
noexcept;
187 template <
typename... Args>
188 USERVER_IMPL_NODEBUG_INLINE_FUNC
LogHelper&
Format(fmt::format_string<Args...>
fmt, Args&&... args)
noexcept {
189 const fmt::string_view fmt_string =
190#if FMT_VERSION >= 120200
193 static_cast<fmt::string_view
>(
fmt);
195 VFormat(fmt_string, fmt::make_format_args(args...));
201 operator impl::Noop() const noexcept {
return {}; }
206 impl::TagWriter GetTagWriter();
211 friend class impl::TagWriter;
213 void DoLog() noexcept;
215 void InternalLoggingError(std::string_view message) noexcept;
217 void PutFloatingPoint(
float value);
218 void PutFloatingPoint(
double value);
219 void PutFloatingPoint(
long double value);
220 void PutUnsigned(
unsigned long long value);
221 void PutSigned(
long long value);
222 void PutBoolean(
bool value);
223 void Put(std::string_view value);
224 void Put(
char value);
226 void PutRaw(std::string_view value_needs_no_escaping);
227 void PutException(const std::exception& ex);
228 void PutQuoted(std::string_view value);
230 void VFormat(fmt::string_view fmt, fmt::format_args args) noexcept;
232 template <typename T>
233 void PutRangeElement(const T& value);
235 template <typename T, typename U>
236 void PutMapElement(const std::pair<const T, U>& value);
238 template <typename T>
239 void PutRange(const T& range);
241 std::ostream& Stream();
245 std::unique_ptr<Impl> pimpl_;
321void LogHelper::PutMapElement(
const std::pair<const T, U>& value) {