userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
log.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/logging/log.hpp
4
/// @brief Logging helpers, see @ref scripts/docs/en/userver/logging.md for more info.
5
6
#
include
<
chrono
>
7
8
#
include
<
userver
/
compiler
/
select
.
hpp
>
9
#
include
<
userver
/
logging
/
fwd
.
hpp
>
10
#
include
<
userver
/
logging
/
level
.
hpp
>
11
#
include
<
userver
/
logging
/
log_filepath
.
hpp
>
12
#
include
<
userver
/
logging
/
log_helper
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
logging {
17
18
namespace
impl {
19
20
void
SetDefaultLoggerRef(LoggerRef new_logger)
noexcept
;
21
22
extern
bool
has_background_threads_which_can_log;
23
24
}
// namespace impl
25
26
/// @brief Returns the default logger previously set by SetDefaultLogger. If the
27
/// logger was not set - returns a logger that does no logging.
28
///
29
/// @note While the coroutine engine is running, any reference to the default
30
/// logger is guaranteed to be alive. No lifetime guarantees are given
31
/// for the default logger reference outside the engine's lifetime. The rule of
32
/// thumb there is not to keep this reference in any extended scope.
33
LoggerRef GetDefaultLogger()
noexcept
;
34
35
/// @brief Atomically replaces the default logger.
36
///
37
/// @warning Do not use this class if you are using a component system.
38
class
DefaultLoggerGuard
final
{
39
public
:
40
/// Atomically replaces the default logger.
41
///
42
/// @warning The logger should live as long as someone is using it.
43
/// Generally speaking - it should live for a lifetime of the application,
44
/// or for a lifetime of the coroutine engine.
45
explicit
DefaultLoggerGuard(LoggerPtr new_default_logger)
noexcept
;
46
47
DefaultLoggerGuard(DefaultLoggerGuard&&) =
delete
;
48
DefaultLoggerGuard& operator=(DefaultLoggerGuard&&) =
delete
;
49
50
~DefaultLoggerGuard();
51
52
private
:
53
LoggerRef logger_prev_;
54
const
Level
level_prev_;
55
LoggerPtr logger_new_;
56
};
57
58
/// @brief Allows to override global log level for the whole service within a scope. Primarily for use in tests.
59
///
60
/// @warning This is NOT the right tool to toggle writing of certain logs within a scope.
61
/// This scope class changes log level GLOBALLY as-if using @ref logging::SetLoggerLevel.
62
///
63
/// @note To affect what logs are written within a scope, use @ref tracing::Span::SetLogLevel and
64
/// @ref tracing::Span::SetLocalLogLevel (read their docs first!).
65
class
DefaultLoggerLevelScope
final
{
66
public
:
67
explicit
DefaultLoggerLevelScope(logging::
Level
level);
68
69
DefaultLoggerLevelScope(DefaultLoggerLevelScope&&) =
delete
;
70
DefaultLoggerLevelScope& operator=(DefaultLoggerLevelScope&&) =
delete
;
71
72
~DefaultLoggerLevelScope();
73
74
private
:
75
impl::LoggerBase& logger_;
76
const
Level
level_initial_;
77
};
78
79
/// @brief Sets new log level for the default logger
80
/// @note Prefer using logging::DefaultLoggerLevelScope if possible
81
void
SetDefaultLoggerLevel(
Level
);
82
83
/// Returns log level for the default logger
84
Level
GetDefaultLoggerLevel()
noexcept
;
85
86
/// Returns true if the provided log level is greater or equal to
87
/// the current log level and to the tracing::Span (if any) local log level.
88
bool
ShouldLog(
Level
level)
noexcept
;
89
90
/// Sets new log level for a logger
91
void
SetLoggerLevel(LoggerRef,
Level
);
92
93
bool
LoggerShouldLog(LoggerRef logger,
Level
level)
noexcept
;
94
95
bool
LoggerShouldLog(
const
LoggerPtr& logger,
Level
level)
noexcept
;
96
97
Level
GetLoggerLevel(LoggerRef logger)
noexcept
;
98
99
/// Forces flush of default logger message queue
100
void
LogFlush();
101
102
/// Forces flush of `logger` message queue
103
void
LogFlush(LoggerRef logger);
104
105
namespace
impl {
106
107
// Not thread-safe, static lifetime data
108
class
RateLimitData {
109
public
:
110
uint64_t count_since_reset = 0;
111
uint64_t dropped_count = 0;
112
std::chrono::steady_clock::time_point last_reset_time{};
113
};
114
115
// Represents a single rate limit usage
116
class
RateLimiter {
117
public
:
118
explicit
RateLimiter(RateLimitData& data)
noexcept
;
119
bool
ShouldLog()
const
noexcept
{
return
should_log_; }
120
auto
GetDroppedCount()
const
noexcept
{
return
dropped_count_; }
121
friend
LogHelper& operator<<(LogHelper& lh,
const
RateLimiter& rl)
noexcept
;
122
123
private
:
124
bool
should_log_{
true
};
125
uint64_t dropped_count_{0};
126
};
127
128
// Register location during static initialization for dynamic debug logs.
129
class
StaticLogEntry
final
{
130
public
:
131
StaticLogEntry(
const
char
* path,
int
line)
noexcept
;
132
133
StaticLogEntry(StaticLogEntry&&) =
delete
;
134
StaticLogEntry& operator=(StaticLogEntry&&) =
delete
;
135
136
bool
ShouldNotLog(LoggerRef logger,
Level
level)
const
noexcept
;
137
bool
ShouldNotLog(
const
LoggerPtr& logger,
Level
level)
const
noexcept
;
138
139
private
:
140
static
constexpr
std::size_t kContentSize =
compiler
::
SelectSize
().For64Bit(40).For32Bit(24);
141
142
alignas
(
void
*) std::byte content_[kContentSize];
143
};
144
145
template
<
class
NameHolder,
int
Line>
146
struct
EntryStorage
final
{
147
static
inline
StaticLogEntry entry{NameHolder::Get(), Line};
148
};
149
150
}
// namespace impl
151
152
}
// namespace logging
153
154
USERVER_NAMESPACE_END
155
156
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
157
158
/// @cond
159
160
#
ifdef
USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
161
162
// Helper macro to erase the logging related code from binary. Erases the
163
// * logging registration via EntryStorage
164
// * ShouldLog() calls and related `if` statements and runtime checks
165
// * SourceLocation info
166
#
define
USERVER_IMPL_ERASE_LOG
(
logger
,
...
)
167
true
168
?
logging
::
impl
::
Noop
{
}
169
:
USERVER_NAMESPACE
::
logging
::
LogHelper
(
170
logger
,
171
USERVER_NAMESPACE
::
logging
::
Level
::
kTrace
,
172
USERVER_NAMESPACE
::
logging
::
LogClass
::
kLog
,
173
USERVER_NAMESPACE
::
utils
::
impl
::
SourceLocation
::
Custom
(
0
,
{
}
,
{
}
)
174
)
175
.
AsLvalue
(
__VA_ARGS__
)
176
177
#
define
USERVER_IMPL_LOGS_TRACE_ERASER
(
MACRO
,
LOGGER
,
...
)
USERVER_IMPL_ERASE_LOG
(
LOGGER
,
__VA_ARGS__
)
178
179
#
if
USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
>
0
180
#
define
USERVER_IMPL_LOGS_DEBUG_ERASER
(
MACRO
,
LOGGER
,
...
)
USERVER_IMPL_ERASE_LOG
(
LOGGER
,
__VA_ARGS__
)
181
#
endif
182
183
#
if
USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
>
1
184
#
define
USERVER_IMPL_LOGS_INFO_ERASER
(
MACRO
,
LOGGER
,
...
)
USERVER_IMPL_ERASE_LOG
(
LOGGER
,
__VA_ARGS__
)
185
#
endif
186
187
#
if
USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
>
2
188
#
define
USERVER_IMPL_LOGS_WARNING_ERASER
(
MACRO
,
LOGGER
,
...
)
USERVER_IMPL_ERASE_LOG
(
LOGGER
,
__VA_ARGS__
)
189
#
endif
190
191
#
if
USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
>
3
192
#
define
USERVER_IMPL_LOGS_ERROR_ERASER
(
MACRO
,
LOGGER
,
...
)
USERVER_IMPL_ERASE_LOG
(
LOGGER
,
__VA_ARGS__
)
193
#
endif
194
195
#
endif
// #ifdef USERVER_FEATURE_ERASE_LOG_WITH_LEVEL
196
197
#
ifndef
USERVER_IMPL_LOGS_TRACE_ERASER
198
#
define
USERVER_IMPL_LOGS_TRACE_ERASER
(
MACRO
,
LOGGER
,
...
)
199
MACRO
(
LOGGER
,
USERVER_NAMESPACE
::
logging
::
Level
::
kTrace
,
__VA_ARGS__
)
200
#
endif
201
202
#
ifndef
USERVER_IMPL_LOGS_DEBUG_ERASER
203
#
define
USERVER_IMPL_LOGS_DEBUG_ERASER
(
MACRO
,
LOGGER
,
...
)
204
MACRO
(
LOGGER
,
USERVER_NAMESPACE
::
logging
::
Level
::
kDebug
,
__VA_ARGS__
)
205
#
endif
206
207
#
ifndef
USERVER_IMPL_LOGS_INFO_ERASER
208
#
define
USERVER_IMPL_LOGS_INFO_ERASER
(
MACRO
,
LOGGER
,
...
)
209
MACRO
(
LOGGER
,
USERVER_NAMESPACE
::
logging
::
Level
::
kInfo
,
__VA_ARGS__
)
210
#
endif
211
212
#
ifndef
USERVER_IMPL_LOGS_WARNING_ERASER
213
#
define
USERVER_IMPL_LOGS_WARNING_ERASER
(
MACRO
,
LOGGER
,
...
)
214
MACRO
(
LOGGER
,
USERVER_NAMESPACE
::
logging
::
Level
::
kWarning
,
__VA_ARGS__
)
215
#
endif
216
217
#
ifndef
USERVER_IMPL_LOGS_ERROR_ERASER
218
#
define
USERVER_IMPL_LOGS_ERROR_ERASER
(
MACRO
,
LOGGER
,
...
)
219
MACRO
(
LOGGER
,
USERVER_NAMESPACE
::
logging
::
Level
::
kError
,
__VA_ARGS__
)
220
#
endif
221
222
#
define
USERVER_IMPL_LOG_TO
(
logger
,
level
,
...
)
223
USERVER_NAMESPACE
::
logging
::
LogHelper
(
logger
,
level
,
USERVER_NAMESPACE
::
logging
::
LogClass
::
kLog
)
224
.
AsLvalue
(
__VA_ARGS__
)
225
226
#
define
USERVER_IMPL_DYNAMIC_DEBUG_ENTRY
227
[
]
(
)
noexcept
->
const
USERVER_NAMESPACE
::
logging
::
impl
::
StaticLogEntry
&
{
228
struct
NameHolder
{
229
static
constexpr
const
char
*
Get
(
)
noexcept
{
return
USERVER_FILEPATH
.
c_str
(
)
;
}
230
}
;
231
const
auto
&
entry
=
USERVER_NAMESPACE
::
logging
::
impl
::
EntryStorage
<
NameHolder
,
__LINE__
>
::
entry
;
232
return
entry
;
233
}
234
/// @endcond
235
236
/// @brief If `lvl` matches the verbosity then builds a stream and evaluates a
237
/// message for the specified `logger`.
238
///
239
/// @param ... optional `fmt::format` string literal and its arguments
240
///
241
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
242
/// @hideinitializer
243
// static_cast<int> below are workarounds for -Wtautological-compare
244
#
define
LOG_TO
(
logger
,
lvl
,
...
)
245
__builtin_expect
(
246
USERVER_IMPL_DYNAMIC_DEBUG_ENTRY
(
)
.
ShouldNotLog
(
(
logger
)
,
(
lvl
)
)
,
247
static_cast
<
int
>
(
lvl
)
<
static_cast
<
int
>
(
USERVER_NAMESPACE
::
logging
::
Level
::
kInfo
)
248
)
249
?
USERVER_NAMESPACE
::
logging
::
impl
::
Noop
{
}
250
:
USERVER_IMPL_LOG_TO
(
(
logger
)
,
(
lvl
)
,
__VA_ARGS__
)
251
252
/// @brief If lvl matches the verbosity then builds a stream and evaluates a
253
/// message for the default logger.
254
///
255
/// @param ... optional `fmt::format` string literal and its arguments
256
///
257
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
258
/// @hideinitializer
259
#
define
LOG
(
lvl
,
...
)
LOG_TO
(
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
(
lvl
)
,
__VA_ARGS__
)
260
261
/// @brief Evaluates a message and logs it to the default logger if its level is
262
/// below or equal to @ref logging::Level::kTrace
263
///
264
/// @param ... optional `fmt::format` string literal and its arguments
265
///
266
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
267
#
define
LOG_TRACE
(
...
)
268
USERVER_IMPL_LOGS_TRACE_ERASER
(
LOG_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
269
270
/// @brief Evaluates a message and logs it to the default logger if its level is
271
/// below or equal to @ref logging::Level::kDebug
272
///
273
/// @param ... optional `fmt::format` string literal and its arguments
274
///
275
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
276
#
define
LOG_DEBUG
(
...
)
277
USERVER_IMPL_LOGS_DEBUG_ERASER
(
LOG_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
278
279
/// @brief Evaluates a message and logs it to the default logger if its level is
280
/// below or equal to @ref logging::Level::kInfo
281
///
282
/// @param ... optional `fmt::format` string literal and its arguments
283
///
284
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
285
#
define
LOG_INFO
(
...
)
USERVER_IMPL_LOGS_INFO_ERASER
(
LOG_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
286
287
/// @brief Evaluates a message and logs it to the default logger if its level is
288
/// below or equal to @ref logging::Level::kWarning
289
///
290
/// @param ... optional `fmt::format` string literal and its arguments
291
///
292
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
293
#
define
LOG_WARNING
(
...
)
294
USERVER_IMPL_LOGS_WARNING_ERASER
(
LOG_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
295
296
/// @brief Evaluates a message and logs it to the default logger if its level is
297
/// below or equal to @ref logging::Level::kError
298
///
299
/// @param ... optional `fmt::format` string literal and its arguments
300
///
301
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
302
#
define
LOG_ERROR
(
...
)
303
USERVER_IMPL_LOGS_ERROR_ERASER
(
LOG_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
304
305
/// @brief Evaluates a message and logs it to the default logger if its level is
306
/// below or equal to @ref logging::Level::kCritical
307
///
308
/// @param ... optional `fmt::format` string literal and its arguments
309
///
310
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
311
#
define
LOG_CRITICAL
(
...
)
LOG
(
USERVER_NAMESPACE
::
logging
::
Level
::
kCritical
,
__VA_ARGS__
)
312
313
///////////////////////////////////////////////////////////////////////////////
314
315
/// @brief Evaluates a message and logs it to the `logger` if its level is below
316
/// or equal to @ref logging::Level::kTrace
317
///
318
/// @param ... optional `fmt::format` string literal and its arguments
319
///
320
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
321
#
define
LOG_TRACE_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_TRACE_ERASER
(
LOG_TO
,
logger
,
__VA_ARGS__
)
322
323
/// @brief Evaluates a message and logs it to the `logger` if its level is below
324
/// or equal to @ref logging::Level::kDebug
325
///
326
/// @param ... optional `fmt::format` string literal and its arguments
327
///
328
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
329
#
define
LOG_DEBUG_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_DEBUG_ERASER
(
LOG_TO
,
logger
,
__VA_ARGS__
)
330
331
/// @brief Evaluates a message and logs it to the `logger` if its level is below
332
/// or equal to @ref logging::Level::kInfo
333
///
334
/// @param ... optional `fmt::format` string literal and its arguments
335
///
336
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
337
#
define
LOG_INFO_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_INFO_ERASER
(
LOG_TO
,
logger
,
__VA_ARGS__
)
338
339
/// @brief Evaluates a message and logs it to the `logger` if its level is below
340
/// or equal to @ref logging::Level::kWarning
341
///
342
/// @param ... optional `fmt::format` string literal and its arguments
343
///
344
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
345
#
define
LOG_WARNING_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_WARNING_ERASER
(
LOG_TO
,
logger
,
__VA_ARGS__
)
346
347
/// @brief Evaluates a message and logs it to the `logger` if its level is below
348
/// or equal to @ref logging::Level::kError
349
///
350
/// @param ... optional `fmt::format` string literal and its arguments
351
///
352
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
353
#
define
LOG_ERROR_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_ERROR_ERASER
(
LOG_TO
,
logger
,
__VA_ARGS__
)
354
355
/// @brief Evaluates a message and logs it to the `logger` if its level is below
356
/// or equal to @ref logging::Level::kCritical
357
///
358
/// @param ... optional `fmt::format` string literal and its arguments
359
///
360
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
361
#
define
LOG_CRITICAL_TO
(
logger
,
...
)
LOG_TO
(
logger
,
USERVER_NAMESPACE
::
logging
::
Level
::
kCritical
,
__VA_ARGS__
)
362
363
///////////////////////////////////////////////////////////////////////////////
364
365
/// @brief If lvl matches the verbosity then builds a stream and evaluates a
366
/// message for the logger. Ignores log messages that occur too often.
367
/// @hideinitializer
368
#
define
LOG_LIMITED_TO
(
logger
,
lvl
,
...
)
369
if
(
const
USERVER_NAMESPACE
::
logging
::
impl
::
RateLimiter
370
userver_log_limited_to_rl
{
[
]
(
)
->
USERVER_NAMESPACE
::
logging
::
impl
::
RateLimitData
&
{
371
thread_local
USERVER_NAMESPACE
::
logging
::
impl
::
RateLimitData
rl_data
;
372
return
rl_data
;
373
}
(
)
}
;
374
!
userver_log_limited_to_rl
.
ShouldLog
(
)
)
375
{
376
}
else
377
LOG_TO
(
(
logger
)
,
(
lvl
)
,
__VA_ARGS__
)
<<
userver_log_limited_to_rl
378
379
/// @brief If lvl matches the verbosity then builds a stream and evaluates a
380
/// message for the default logger. Ignores log messages that occur too often.
381
///
382
/// @param ... optional `fmt::format` string literal and its arguments
383
///
384
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
385
#
define
LOG_LIMITED
(
lvl
,
...
)
LOG_LIMITED_TO
(
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
(
lvl
)
,
__VA_ARGS__
)
386
387
/// @brief Evaluates a message and logs it to the default logger if the log
388
/// message does not occur too often and default logger level is below or equal
389
/// to @ref logging::Level::kTrace.
390
///
391
/// @param ... optional `fmt::format` string literal and its arguments
392
///
393
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
394
#
define
LOG_LIMITED_TRACE
(
...
)
395
USERVER_IMPL_LOGS_TRACE_ERASER
(
LOG_LIMITED_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
396
397
/// @brief Evaluates a message and logs it to the default logger if the log
398
/// message does not occur too often and default logger level is below or equal
399
/// to @ref logging::Level::kDebug.
400
///
401
/// @param ... optional `fmt::format` string literal and its arguments
402
///
403
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
404
#
define
LOG_LIMITED_DEBUG
(
...
)
405
USERVER_IMPL_LOGS_DEBUG_ERASER
(
LOG_LIMITED_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
406
407
/// @brief Evaluates a message and logs it to the default logger if the log
408
/// message does not occur too often and default logger level is below or equal
409
/// to @ref logging::Level::kInfo.
410
///
411
/// @param ... optional `fmt::format` string literal and its arguments
412
///
413
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
414
#
define
LOG_LIMITED_INFO
(
...
)
415
USERVER_IMPL_LOGS_INFO_ERASER
(
LOG_LIMITED_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
416
417
/// @brief Evaluates a message and logs it to the default logger if the log
418
/// message does not occur too often and default logger level is below or equal
419
/// to @ref logging::Level::kWarning.
420
///
421
/// @param ... optional `fmt::format` string literal and its arguments
422
///
423
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
424
#
define
LOG_LIMITED_WARNING
(
...
)
425
USERVER_IMPL_LOGS_WARNING_ERASER
(
LOG_LIMITED_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
426
427
/// @brief Evaluates a message and logs it to the default logger if the log
428
/// message does not occur too often and default logger level is below or equal
429
/// to @ref logging::Level::kError.
430
///
431
/// @param ... optional `fmt::format` string literal and its arguments
432
///
433
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
434
#
define
LOG_LIMITED_ERROR
(
...
)
435
USERVER_IMPL_LOGS_ERROR_ERASER
(
LOG_LIMITED_TO
,
USERVER_NAMESPACE
::
logging
::
GetDefaultLogger
(
)
,
__VA_ARGS__
)
436
437
/// @brief Evaluates a message and logs it to the default logger if the log
438
/// message does not occur too often and default logger level is below or equal
439
/// to @ref logging::Level::kCritical.
440
///
441
/// @param ... optional `fmt::format` string literal and its arguments
442
///
443
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
444
#
define
LOG_LIMITED_CRITICAL
(
...
)
LOG_LIMITED
(
USERVER_NAMESPACE
::
logging
::
Level
::
kCritical
,
__VA_ARGS__
)
445
446
///////////////////////////////////////////////////////////////////////////////
447
448
/// @brief Evaluates a message and logs it to the `logger` if the log message
449
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kTrace.
450
///
451
/// @param ... optional `fmt::format` string literal and its arguments
452
///
453
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
454
#
define
LOG_LIMITED_TRACE_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_TRACE_ERASER
(
LOG_LIMITED_TO
,
logger
,
__VA_ARGS__
)
455
456
/// @brief Evaluates a message and logs it to the `logger` if the log message
457
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kDebug.
458
///
459
/// @param ... optional `fmt::format` string literal and its arguments
460
///
461
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
462
#
define
LOG_LIMITED_DEBUG_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_DEBUG_ERASER
(
LOG_LIMITED_TO
,
logger
,
__VA_ARGS__
)
463
464
/// @brief Evaluates a message and logs it to the `logger` if the log message
465
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kInfo.
466
///
467
/// @param ... optional `fmt::format` string literal and its arguments
468
///
469
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
470
#
define
LOG_LIMITED_INFO_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_INFO_ERASER
(
LOG_LIMITED_TO
,
logger
,
__VA_ARGS__
)
471
472
/// @brief Evaluates a message and logs it to the `logger` if the log message
473
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kWarning.
474
///
475
/// @param ... optional `fmt::format` string literal and its arguments
476
///
477
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
478
#
define
LOG_LIMITED_WARNING_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_WARNING_ERASER
(
LOG_LIMITED_TO
,
logger
,
__VA_ARGS__
)
479
480
/// @brief Evaluates a message and logs it to the `logger` if the log message
481
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kError.
482
///
483
/// @param ... optional `fmt::format` string literal and its arguments
484
///
485
/// Affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
486
#
define
LOG_LIMITED_ERROR_TO
(
logger
,
...
)
USERVER_IMPL_LOGS_ERROR_ERASER
(
LOG_LIMITED_TO
,
logger
,
__VA_ARGS__
)
487
488
/// @brief Evaluates a message and logs it to the `logger` if the log message
489
/// does not occur too often and `logger` level is below or equal to @ref logging::Level::kCritical.
490
///
491
/// @param ... optional `fmt::format` string literal and its arguments
492
///
493
/// Not affected by `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` @ref scripts/docs/en/userver/build/options.md "CMake option".
494
#
define
LOG_LIMITED_CRITICAL_TO
(
logger
,
...
)
495
LOG_LIMITED_TO
(
logger
,
USERVER_NAMESPACE
::
logging
::
Level
::
kCritical
,
__VA_ARGS__
)
496
497
// NOLINTEND(cppcoreguidelines-macro-usage)
userver
logging
log.hpp
Generated on
for userver by
Doxygen
1.17.0