Bitcoin ABC 0.32.4
P2P Digital Currency
logging.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Copyright (c) 2017-2019 The Bitcoin developers
4// Distributed under the MIT software license, see the accompanying
5// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7#ifndef BITCOIN_LOGGING_H
8#define BITCOIN_LOGGING_H
9
10#include <crypto/siphash.h>
11#include <span.h>
12#include <threadsafety.h>
13#include <tinyformat.h>
14#include <util/fs.h>
15#include <util/string.h>
16#include <util/time.h>
17
18#include <atomic>
19#include <cstdint>
20#include <cstring>
21#include <functional>
22#include <list>
23#include <memory>
24#include <mutex>
25#include <source_location>
26#include <string>
27#include <unordered_map>
28#include <unordered_set>
29#include <vector>
30
31static const bool DEFAULT_LOGTIMEMICROS = false;
32static const bool DEFAULT_LOGIPS = false;
33static const bool DEFAULT_LOGTIMESTAMPS = true;
34static const bool DEFAULT_LOGTHREADNAMES = false;
35static const bool DEFAULT_LOGSOURCELOCATIONS = false;
36static constexpr bool DEFAULT_LOGLEVELALWAYS = false;
37
38extern bool fLogIPs;
39extern const char *const DEFAULT_DEBUGLOGFILE;
40
42 bool operator()(const std::source_location &lhs,
43 const std::source_location &rhs) const noexcept {
44 return lhs.line() == rhs.line() &&
45 std::string_view(lhs.file_name()) ==
46 std::string_view(rhs.file_name());
47 }
48};
49
51 size_t operator()(const std::source_location &s) const noexcept {
52 // Use CSipHasher(0, 0) as a simple way to get uniform distribution.
53 return size_t(CSipHasher(0, 0)
54 .Write(s.line())
55 .Write(MakeUCharSpan(std::string_view{s.file_name()}))
56 .Finalize());
57 }
58};
59
61 std::string category;
62 bool active;
63};
64
65namespace BCLog {
66
67enum LogFlags : uint32_t {
68 NONE = 0,
69 NET = (1 << 0),
70 TOR = (1 << 1),
71 MEMPOOL = (1 << 2),
72 HTTP = (1 << 3),
73 BENCH = (1 << 4),
74 ZMQ = (1 << 5),
75 WALLETDB = (1 << 6),
76 RPC = (1 << 7),
77 ESTIMATEFEE = (1 << 8),
78 ADDRMAN = (1 << 9),
79 SELECTCOINS = (1 << 10),
80 REINDEX = (1 << 11),
81 CMPCTBLOCK = (1 << 12),
82 RAND = (1 << 13),
83 PRUNE = (1 << 14),
84 PROXY = (1 << 15),
85 MEMPOOLREJ = (1 << 16),
86 LIBEVENT = (1 << 17),
87 COINDB = (1 << 18),
88 QT = (1 << 19),
89 LEVELDB = (1 << 20),
90 VALIDATION = (1 << 21),
91 AVALANCHE = (1 << 22),
92 I2P = (1 << 23),
93 CHRONIK = (1 << 24),
94#ifdef DEBUG_LOCKCONTENTION
95 LOCK = (1 << 25),
96#endif
97 BLOCKSTORE = (1 << 26),
98 NETDEBUG = (1 << 27),
99 TXPACKAGES = (1 << 28),
100 ALL = ~uint32_t(0),
101};
102
103enum class Level {
104 // High-volume or detailed logging for development/debugging
105 Trace = 0,
106 // Reasonably noisy logging, but still usable in production
107 Debug,
108 // Default
109 Info,
110 Warning,
111 Error,
112};
114// buffer up to 1MB of log data prior to StartLogging
115constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000};
116// maximum number of bytes per source location that can be logged within the
117// RATELIMIT_WINDOW
118constexpr uint64_t RATELIMIT_MAX_BYTES{1024 * 1024};
119// time window after which log ratelimit stats are reset
120constexpr auto RATELIMIT_WINDOW{1h};
121constexpr bool DEFAULT_LOGRATELIMIT{true};
122
125public:
128 struct Stats {
133 uint64_t m_dropped_bytes{0};
134
135 Stats(uint64_t max_bytes) : m_available_bytes{max_bytes} {}
138 bool Consume(uint64_t bytes);
139 };
140
141private:
143
145 std::unordered_map<std::source_location, Stats, SourceLocationHasher,
147 m_source_locations GUARDED_BY(m_mutex);
150 std::atomic<bool> m_suppression_active{false};
151 LogRateLimiter(uint64_t max_bytes, std::chrono::seconds reset_window);
152
153public:
155 std::function<void(std::function<bool()>, std::chrono::milliseconds)>;
165 static std::shared_ptr<LogRateLimiter>
166 Create(SchedulerFunction &&scheduler_func, uint64_t max_bytes,
167 std::chrono::seconds reset_window);
169 const uint64_t m_max_bytes;
171 const std::chrono::seconds m_reset_window;
173 enum class Status {
174 // string fits within the limit
175 UNSUPPRESSED,
176 // suppression has started since this string
177 NEWLY_SUPPRESSED,
178 // suppression is still ongoing
179 STILL_SUPPRESSED,
180 };
183 [[nodiscard]] Status Consume(const std::source_location &source_loc,
184 const std::string &str)
190};
191
192class Logger {
193public:
194 struct BufferedLog {
195 SystemClock::time_point now;
196 std::chrono::seconds mocktime;
197 std::string str, threadname;
198 std::source_location source_loc;
201 };
202
203private:
204 // Can not use Mutex from sync.h because in debug mode it would cause a
205 // deadlock when a potential deadlock was detected
206 mutable StdMutex m_cs;
207
208 FILE *m_fileout GUARDED_BY(m_cs) = nullptr;
209 std::list<BufferedLog> m_msgs_before_open GUARDED_BY(m_cs);
211 bool m_buffering GUARDED_BY(m_cs) = true;
212 size_t m_max_buffer_memusage GUARDED_BY(m_cs){DEFAULT_MAX_LOG_BUFFER};
213 size_t m_cur_buffer_memusage GUARDED_BY(m_cs){0};
214 size_t m_buffer_lines_discarded GUARDED_BY(m_cs){0};
215
220 std::atomic_bool m_started_new_line{true};
221
223 std::shared_ptr<LogRateLimiter> m_limiter GUARDED_BY(m_cs);
224
226 std::unordered_map<LogFlags, Level> m_category_log_levels GUARDED_BY(m_cs);
227
230 std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
231
235 std::atomic<uint32_t> m_categories{0};
236
237 void FormatLogStrInPlace(std::string &str, LogFlags category, Level level,
238 const std::source_location &source_loc,
239 std::string_view threadname,
240 SystemClock::time_point now,
241 std::chrono::seconds mocktime) const;
242
243 std::string LogTimestampStr(SystemClock::time_point now,
244 std::chrono::seconds mocktime) const;
245
247 std::list<std::function<void(const std::string &)>>
248 m_print_callbacks GUARDED_BY(m_cs){};
249
251 void LogPrintStr_(std::string_view str, std::source_location &&source_loc,
252 BCLog::LogFlags category, BCLog::Level level,
253 bool should_ratelimit) EXCLUSIVE_LOCKS_REQUIRED(m_cs);
254
255public:
256 bool m_print_to_console = false;
257 bool m_print_to_file = false;
258
264
266 std::atomic<bool> m_reopen_file{false};
267
268 std::string GetLogPrefix(LogFlags category, Level level) const;
269
270 ~Logger();
271
273 void LogPrintStr(std::string_view str, std::source_location &&source_loc,
274 BCLog::LogFlags category, BCLog::Level level,
275 bool should_ratelimit);
276
279 StdLockGuard scoped_lock(m_cs);
280 return m_buffering || m_print_to_console || m_print_to_file ||
281 !m_print_callbacks.empty();
282 }
283
285 std::list<std::function<void(const std::string &)>>::iterator
286 PushBackCallback(std::function<void(const std::string &)> fun)
288 StdLockGuard scoped_lock(m_cs);
289 m_print_callbacks.push_back(std::move(fun));
290 return --m_print_callbacks.end();
291 }
292
295 std::list<std::function<void(const std::string &)>>::iterator it)
297 StdLockGuard scoped_lock(m_cs);
298 m_print_callbacks.erase(it);
299 }
300
305
313
314 void SetRateLimiting(std::shared_ptr<LogRateLimiter> limiter)
316 StdLockGuard scoped_lock(m_cs);
317 m_limiter = std::move(limiter);
318 }
319
320 void ShrinkDebugFile();
321
322 std::unordered_map<LogFlags, Level> CategoryLevels() const
324 StdLockGuard scoped_lock(m_cs);
325 return m_category_log_levels;
326 }
327 void SetCategoryLogLevel(const std::unordered_map<LogFlags, Level> &levels)
329 StdLockGuard scoped_lock(m_cs);
330 m_category_log_levels = levels;
331 }
332 bool SetCategoryLogLevel(std::string_view category_str,
333 std::string_view level_str)
335
336 Level LogLevel() const { return m_log_level.load(); }
337 void SetLogLevel(Level level) { m_log_level = level; }
338 bool SetLogLevel(std::string_view level);
339
340 uint32_t GetCategoryMask() const { return m_categories.load(); }
341
342 void EnableCategory(LogFlags category);
343 bool EnableCategory(std::string_view str);
344 void DisableCategory(LogFlags category);
345 bool DisableCategory(std::string_view str);
346
348 bool WillLogCategory(LogFlags category) const;
349 bool WillLogCategoryLevel(LogFlags category, Level level) const
351
353 std::vector<LogCategory> LogCategoriesList() const;
355 std::string LogCategoriesString() const {
356 return Join(LogCategoriesList(), ", ",
357 [&](const LogCategory &i) { return i.category; });
358 };
359
361 std::string LogLevelsString() const;
362
364 static std::string LogLevelToStr(BCLog::Level level);
365
367 bool DefaultShrinkDebugFile() const;
368};
369
370} // namespace BCLog
371
373
375static inline bool LogAcceptCategory(BCLog::LogFlags category,
376 BCLog::Level level) {
377 return LogInstance().WillLogCategoryLevel(category, level);
378}
379
381bool GetLogCategory(BCLog::LogFlags &flag, std::string_view str);
382
383// Be conservative when using LogPrintf/error or other things which
384// unconditionally log to debug.log! It should not be the case that an inbound
385// peer can fill up a user's disk with debug.log entries.
386template <typename... Args>
387static inline void LogPrintf_(std::source_location &&source_loc,
388 BCLog::LogFlags flag, BCLog::Level level,
389 bool should_ratelimit, const char *fmt,
390 const Args &...args) {
391 if (LogInstance().Enabled()) {
392 std::string log_msg;
393 try {
394 log_msg = tfm::format(fmt, args...);
395 } catch (tinyformat::format_error &fmterr) {
399 log_msg = "Error \"" + std::string(fmterr.what()) +
400 "\" while formatting log message: " + fmt;
401 }
402 LogInstance().LogPrintStr(log_msg, std::move(source_loc), flag, level,
403 should_ratelimit);
404 }
405}
406
407#define LogPrintLevel_(category, level, should_ratelimit, ...) \
408 LogPrintf_(std::source_location::current(), category, level, \
409 should_ratelimit, __VA_ARGS__)
410
411// Log unconditionally. Uses basic rate limiting to mitigate disk filling
412// attacks.
413#define LogInfo(...) \
414 LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, \
415 /*should_ratelimit=*/true, __VA_ARGS__)
416#define LogWarning(...) \
417 LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, \
418 /*should_ratelimit=*/true, __VA_ARGS__)
419#define LogError(...) \
420 LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, \
421 /*should_ratelimit=*/true, __VA_ARGS__)
422
423// Deprecated unconditional logging.
424#define LogPrintf(...) LogInfo(__VA_ARGS__)
425
426// Use a macro instead of a function for conditional logging to prevent
427// evaluating arguments when logging for the category is not enabled.
428
429// Log by prefixing the output with the passed category name and severity level.
430// This can either log conditionally if the category is allowed or
431// unconditionally if level >= BCLog::Level::Info is passed. If this function
432// logs unconditionally, logging to disk is rate-limited. This is important so
433// that callers don't need to worry about accidentally introducing a disk-fill
434// vulnerability if level >= Info is used. Additionally, users specifying -debug
435// are assumed to be developers or power users who are aware that -debug may
436// cause excessive disk usage due to logging.
437#define LogPrintLevel(category, level, ...) \
438 do { \
439 if (LogAcceptCategory((category), (level))) { \
440 bool rate_limit{level >= BCLog::Level::Info}; \
441 LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \
442 } \
443 } while (0)
444
445// Log conditionally, prefixing the output with the passed category name.
446#define LogDebug(category, ...) \
447 LogPrintLevel(category, BCLog::Level::Debug, __VA_ARGS__)
448#define LogTrace(category, ...) \
449 LogPrintLevel(category, BCLog::Level::Trace, __VA_ARGS__)
450
451// Deprecated conditional logging
452#define LogPrint(category, ...) LogDebug(category, __VA_ARGS__)
453
459#define LogPrintfToBeContinued LogPrintf
460#define LogPrintToBeContinued LogPrint
461#define LogPrintLevelToBeContinued LogPrintLevel
462
463#endif // BITCOIN_LOGGING_H
Fixed window rate limiter for logging.
Definition: logging.h:124
std::unordered_map< std::source_location, Stats, SourceLocationHasher, SourceLocationEqual > m_source_locations GUARDED_BY(m_mutex)
Stats for each source location that has attempted to log something.
static std::shared_ptr< LogRateLimiter > Create(SchedulerFunction &&scheduler_func, uint64_t max_bytes, std::chrono::seconds reset_window)
Definition: logging.cpp:364
std::function< void(std::function< bool()>, std::chrono::milliseconds)> SchedulerFunction
Definition: logging.h:155
const uint64_t m_max_bytes
Maximum number of bytes logged per location per window.
Definition: logging.h:169
LogRateLimiter(uint64_t max_bytes, std::chrono::seconds reset_window)
Definition: logging.cpp:359
Status Consume(const std::source_location &source_loc, const std::string &str) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Consumes source_loc's available bytes corresponding to the size of the (formatted) str and returns it...
Definition: logging.cpp:381
bool SuppressionsActive() const
Returns true if any log locations are currently being suppressed.
Definition: logging.h:189
const std::chrono::seconds m_reset_window
Interval after which the window is reset.
Definition: logging.h:171
Status
Suppression status of a source log location.
Definition: logging.h:173
void Reset() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Resets all usage to zero. Called periodically by the scheduler.
Definition: logging.cpp:634
std::atomic< bool > m_suppression_active
Whether any log locations are suppressed.
Definition: logging.h:150
static std::string LogLevelToStr(BCLog::Level level)
Returns the string representation of a log level.
Definition: logging.cpp:202
bool m_always_print_category_level
Definition: logging.h:263
size_t m_buffer_lines_discarded GUARDED_BY(m_cs)
Definition: logging.h:214
FILE *m_fileout GUARDED_BY(m_cs)
bool m_buffering GUARDED_BY(m_cs)
Buffer messages before logging can be started.
void LogPrintStr(std::string_view str, std::source_location &&source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit)
Send a string to the log output.
Definition: logging.cpp:417
bool WillLogCategory(LogFlags category) const
Return true if log accepts specified category.
Definition: logging.cpp:600
std::list< BufferedLog > m_msgs_before_open GUARDED_BY(m_cs)
std::string LogTimestampStr(SystemClock::time_point now, std::chrono::seconds mocktime) const
Definition: logging.cpp:269
std::atomic< uint32_t > m_categories
Log categories bitfield.
Definition: logging.h:235
size_t m_cur_buffer_memusage GUARDED_BY(m_cs)
Definition: logging.h:213
bool DefaultShrinkDebugFile() const
Default for whether ShrinkDebugFile should be run.
Definition: logging.cpp:630
std::unordered_map< LogFlags, Level > m_category_log_levels GUARDED_BY(m_cs)
Category-specific log level. Overrides m_log_level.
bool m_log_sourcelocations
Definition: logging.h:262
void SetCategoryLogLevel(const std::unordered_map< LogFlags, Level > &levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:327
void SetLogLevel(Level level)
Definition: logging.h:337
std::atomic< Level > m_log_level
If there is no category-specific log level, all logs with a severity level lower than m_log_level wil...
Definition: logging.h:230
Level LogLevel() const
Definition: logging.h:336
bool WillLogCategoryLevel(LogFlags category, Level level) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.cpp:612
fs::path m_file_path
Definition: logging.h:265
bool m_log_time_micros
Definition: logging.h:260
bool m_log_threadnames
Definition: logging.h:261
std::list< std::function< void(conststd::string &)> >::iterator PushBackCallback(std::function< void(const std::string &)> fun) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Connect a slot to the print signal and return the connection.
Definition: logging.h:286
std::atomic_bool m_started_new_line
m_started_new_line is a state variable that will suppress printing of the timestamp when multiple cal...
Definition: logging.h:220
void SetRateLimiting(std::shared_ptr< LogRateLimiter > limiter) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:314
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
This offers a slight speedup and slightly smaller memory usage compared to leaving the logging system...
Definition: logging.cpp:119
std::vector< LogCategory > LogCategoriesList() const
Returns a vector of the log categories in alphabetical order.
Definition: logging.cpp:240
bool StartLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Start logging (and flush all buffered messages)
Definition: logging.cpp:49
void DisableCategory(LogFlags category)
Definition: logging.cpp:587
size_t m_max_buffer_memusage GUARDED_BY(m_cs)
Definition: logging.h:212
void EnableCategory(LogFlags category)
Definition: logging.cpp:574
bool m_log_timestamps
Definition: logging.h:259
void DeleteCallback(std::list< std::function< void(const std::string &)> >::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Delete a connection.
Definition: logging.h:294
std::string GetLogPrefix(LogFlags category, Level level) const
Definition: logging.cpp:318
void LogPrintStr_(std::string_view str, std::source_location &&source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit) EXCLUSIVE_LOCKS_REQUIRED(m_cs)
Send a string to the log output (internal)
Definition: logging.cpp:426
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition: logging.cpp:105
std::string LogLevelsString() const
Returns a string with all user-selectable log levels.
Definition: logging.cpp:262
std::atomic< bool > m_reopen_file
Definition: logging.h:266
void ShrinkDebugFile()
Definition: logging.cpp:535
bool m_print_to_file
Definition: logging.h:257
void FormatLogStrInPlace(std::string &str, LogFlags category, Level level, const std::source_location &source_loc, std::string_view threadname, SystemClock::time_point now, std::chrono::seconds mocktime) const
Definition: logging.cpp:397
uint32_t GetCategoryMask() const
Definition: logging.h:340
std::unordered_map< LogFlags, Level > CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:322
bool m_print_to_console
Definition: logging.h:256
std::shared_ptr< LogRateLimiter > m_limiter GUARDED_BY(m_cs)
Manages the rate limiting of each log location.
std::list< std::function< void(const std::string &)> > m_print_callbacks GUARDED_BY(m_cs)
Slots that connect to the print signal.
Definition: logging.h:248
StdMutex m_cs
Definition: logging.h:206
bool Enabled() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Returns whether logs will be written to any output.
Definition: logging.h:278
std::string LogCategoriesString() const
Returns a string with the log categories in alphabetical order.
Definition: logging.h:355
SipHash-2-4.
Definition: siphash.h:14
CSipHasher & Write(uint64_t data)
Hash a 64-bit integer worth of data.
Definition: siphash.cpp:36
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
static const bool DEFAULT_LOGTIMESTAMPS
Definition: logging.h:33
bool GetLogCategory(BCLog::LogFlags &flag, std::string_view str)
Return true if str parses as a log category and set the flag.
Definition: logging.cpp:189
static const bool DEFAULT_LOGIPS
Definition: logging.h:32
static const bool DEFAULT_LOGTHREADNAMES
Definition: logging.h:34
static bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level level)
Return true if log accepts specified category, at the specified level.
Definition: logging.h:375
static void LogPrintf_(std::source_location &&source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, const char *fmt, const Args &...args)
Definition: logging.h:387
BCLog::Logger & LogInstance()
Definition: logging.cpp:25
static const bool DEFAULT_LOGSOURCELOCATIONS
Definition: logging.h:35
bool fLogIPs
Definition: logging.cpp:21
static const bool DEFAULT_LOGTIMEMICROS
Definition: logging.h:31
const char *const DEFAULT_DEBUGLOGFILE
Definition: logging.cpp:22
static constexpr bool DEFAULT_LOGLEVELALWAYS
Definition: logging.h:36
constexpr auto RATELIMIT_WINDOW
Definition: logging.h:120
Level
Definition: logging.h:103
constexpr bool DEFAULT_LOGRATELIMIT
Definition: logging.h:121
constexpr uint64_t RATELIMIT_MAX_BYTES
Definition: logging.h:118
constexpr size_t DEFAULT_MAX_LOG_BUFFER
Definition: logging.h:115
LogFlags
Definition: logging.h:67
@ ESTIMATEFEE
Definition: logging.h:77
@ AVALANCHE
Definition: logging.h:91
@ RAND
Definition: logging.h:82
@ COINDB
Definition: logging.h:87
@ REINDEX
Definition: logging.h:80
@ TXPACKAGES
Definition: logging.h:99
@ WALLETDB
Definition: logging.h:75
@ ADDRMAN
Definition: logging.h:78
@ ALL
Definition: logging.h:100
@ NETDEBUG
Definition: logging.h:98
@ RPC
Definition: logging.h:76
@ HTTP
Definition: logging.h:72
@ LEVELDB
Definition: logging.h:89
@ NONE
Definition: logging.h:68
@ VALIDATION
Definition: logging.h:90
@ MEMPOOLREJ
Definition: logging.h:85
@ PRUNE
Definition: logging.h:83
@ TOR
Definition: logging.h:70
@ LIBEVENT
Definition: logging.h:86
@ CMPCTBLOCK
Definition: logging.h:81
@ PROXY
Definition: logging.h:84
@ CHRONIK
Definition: logging.h:93
@ ZMQ
Definition: logging.h:74
@ MEMPOOL
Definition: logging.h:71
@ SELECTCOINS
Definition: logging.h:79
@ I2P
Definition: logging.h:92
@ BENCH
Definition: logging.h:73
@ NET
Definition: logging.h:69
@ QT
Definition: logging.h:88
@ BLOCKSTORE
Definition: logging.h:97
constexpr auto DEFAULT_LOG_LEVEL
Definition: logging.h:113
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:259
void format(std::ostream &out, const char *fmt, const Args &...args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1112
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span{std::forward< V >(v)}))
Like the Span constructor, but for (const) uint8_t member types only.
Definition: span.h:350
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Definition: string.h:63
Keeps track of an individual source location and how many available bytes are left for logging from i...
Definition: logging.h:128
uint64_t m_available_bytes
Remaining bytes.
Definition: logging.h:130
Stats(uint64_t max_bytes)
Definition: logging.h:135
bool Consume(uint64_t bytes)
Updates internal accounting and returns true if enough available_bytes were remaining.
Definition: logging.cpp:655
uint64_t m_dropped_bytes
Number of bytes that were consumed but didn't fit in the available bytes.
Definition: logging.h:133
std::chrono::seconds mocktime
Definition: logging.h:196
std::string threadname
Definition: logging.h:197
std::source_location source_loc
Definition: logging.h:198
SystemClock::time_point now
Definition: logging.h:195
bool active
Definition: logging.h:62
std::string category
Definition: logging.h:61
bool operator()(const std::source_location &lhs, const std::source_location &rhs) const noexcept
Definition: logging.h:42
size_t operator()(const std::source_location &s) const noexcept
Definition: logging.h:51
#define LOCK(cs)
Definition: sync.h:306
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56