Bitcoin Core 30.99.0
P2P Digital Currency
logging.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-present The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_LOGGING_H
7#define BITCOIN_LOGGING_H
8
9#include <crypto/siphash.h>
10#include <threadsafety.h>
11#include <tinyformat.h>
12#include <util/check.h>
13#include <util/fs.h>
14#include <util/string.h>
15#include <util/time.h>
16
17#include <atomic>
18#include <cstdint>
19#include <cstring>
20#include <functional>
21#include <list>
22#include <memory>
23#include <mutex>
24#include <source_location>
25#include <string>
26#include <unordered_map>
27#include <unordered_set>
28#include <vector>
29
30static const bool DEFAULT_LOGTIMEMICROS = false;
31static const bool DEFAULT_LOGIPS = false;
32static const bool DEFAULT_LOGTIMESTAMPS = true;
33static const bool DEFAULT_LOGTHREADNAMES = false;
34static const bool DEFAULT_LOGSOURCELOCATIONS = false;
35static constexpr bool DEFAULT_LOGLEVELALWAYS = false;
36extern const char * const DEFAULT_DEBUGLOGFILE;
37
38extern bool fLogIPs;
39
42{
43public:
47 SourceLocation(const char* func,
48 std::source_location loc = std::source_location::current())
49 : m_func{func}, m_loc{loc} {}
50
51 std::string_view file_name() const { return m_loc.file_name(); }
52 std::uint_least32_t line() const { return m_loc.line(); }
53 std::string_view function_name_short() const { return m_func; }
54
55private:
56 std::string_view m_func;
57 std::source_location m_loc;
58};
59
61 bool operator()(const SourceLocation& lhs, const SourceLocation& rhs) const noexcept
62 {
63 return lhs.line() == rhs.line() && std::string_view(lhs.file_name()) == std::string_view(rhs.file_name());
64 }
65};
66
68 size_t operator()(const SourceLocation& s) const noexcept
69 {
70 // Use CSipHasher(0, 0) as a simple way to get uniform distribution.
71 return size_t(CSipHasher(0, 0)
72 .Write(s.line())
73 .Write(MakeUCharSpan(std::string_view{s.file_name()}))
74 .Finalize());
75 }
76};
77
79 std::string category;
80 bool active;
81};
82
83namespace BCLog {
84 using CategoryMask = uint64_t;
87 NET = (CategoryMask{1} << 0),
88 TOR = (CategoryMask{1} << 1),
89 MEMPOOL = (CategoryMask{1} << 2),
90 HTTP = (CategoryMask{1} << 3),
91 BENCH = (CategoryMask{1} << 4),
92 ZMQ = (CategoryMask{1} << 5),
94 RPC = (CategoryMask{1} << 7),
96 ADDRMAN = (CategoryMask{1} << 9),
98 REINDEX = (CategoryMask{1} << 11),
100 RAND = (CategoryMask{1} << 13),
101 PRUNE = (CategoryMask{1} << 14),
102 PROXY = (CategoryMask{1} << 15),
104 LIBEVENT = (CategoryMask{1} << 17),
105 COINDB = (CategoryMask{1} << 18),
106 QT = (CategoryMask{1} << 19),
107 LEVELDB = (CategoryMask{1} << 20),
109 I2P = (CategoryMask{1} << 22),
110 IPC = (CategoryMask{1} << 23),
111#ifdef DEBUG_LOCKCONTENTION
112 LOCK = (CategoryMask{1} << 24),
113#endif
116 SCAN = (CategoryMask{1} << 27),
118 KERNEL = (CategoryMask{1} << 29),
121 };
122 enum class Level {
123 Trace = 0, // High-volume or detailed logging for development/debugging
124 Debug, // Reasonably noisy logging, but still usable in production
125 Info, // Default
126 Warning,
127 Error,
128 };
130 constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000}; // buffer up to 1MB of log data prior to StartLogging
131 constexpr uint64_t RATELIMIT_MAX_BYTES{1024 * 1024}; // maximum number of bytes per source location that can be logged within the RATELIMIT_WINDOW
132 constexpr auto RATELIMIT_WINDOW{1h}; // time window after which log ratelimit stats are reset
133 constexpr bool DEFAULT_LOGRATELIMIT{true};
134
137 {
138 public:
140 struct Stats {
144 uint64_t m_dropped_bytes{0};
145
146 Stats(uint64_t max_bytes) : m_available_bytes{max_bytes} {}
148 bool Consume(uint64_t bytes);
149 };
150
151 private:
153
155 std::unordered_map<SourceLocation, Stats, SourceLocationHasher, SourceLocationEqual> m_source_locations GUARDED_BY(m_mutex);
157 std::atomic<bool> m_suppression_active{false};
158 LogRateLimiter(uint64_t max_bytes, std::chrono::seconds reset_window);
159
160 public:
161 using SchedulerFunction = std::function<void(std::function<void()>, std::chrono::milliseconds)>;
170 static std::shared_ptr<LogRateLimiter> Create(
171 SchedulerFunction&& scheduler_func,
172 uint64_t max_bytes,
173 std::chrono::seconds reset_window);
175 const uint64_t m_max_bytes;
177 const std::chrono::seconds m_reset_window;
179 enum class Status {
180 UNSUPPRESSED, // string fits within the limit
181 NEWLY_SUPPRESSED, // suppression has started since this string
182 STILL_SUPPRESSED, // suppression is still ongoing
183 };
186 [[nodiscard]] Status Consume(
187 const SourceLocation& source_loc,
188 const std::string& str) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
193 };
194
195 class Logger
196 {
197 public:
198 struct BufferedLog {
199 SystemClock::time_point now;
200 std::chrono::seconds mocktime;
201 std::string str, threadname;
205 };
206
207 private:
208 mutable StdMutex m_cs; // Can not use Mutex from sync.h because in debug mode it would cause a deadlock when a potential deadlock was detected
209
210 FILE* m_fileout GUARDED_BY(m_cs) = nullptr;
211 std::list<BufferedLog> m_msgs_before_open GUARDED_BY(m_cs);
212 bool m_buffering GUARDED_BY(m_cs) = true;
213 size_t m_max_buffer_memusage GUARDED_BY(m_cs){DEFAULT_MAX_LOG_BUFFER};
214 size_t m_cur_buffer_memusage GUARDED_BY(m_cs){0};
215 size_t m_buffer_lines_discarded GUARDED_BY(m_cs){0};
216
218 std::shared_ptr<LogRateLimiter> m_limiter GUARDED_BY(m_cs);
219
221 std::unordered_map<LogFlags, Level> m_category_log_levels GUARDED_BY(m_cs);
222
225 std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
226
228 std::atomic<CategoryMask> m_categories{BCLog::NONE};
229
230 void FormatLogStrInPlace(std::string& str, LogFlags category, Level level, const SourceLocation& source_loc, std::string_view threadname, SystemClock::time_point now, std::chrono::seconds mocktime) const;
231
232 std::string LogTimestampStr(SystemClock::time_point now, std::chrono::seconds mocktime) const;
233
235 std::list<std::function<void(const std::string&)>> m_print_callbacks GUARDED_BY(m_cs) {};
236
238 void LogPrintStr_(std::string_view str, SourceLocation&& source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit)
240
241 std::string GetLogPrefix(LogFlags category, Level level) const;
242
243 public:
244 bool m_print_to_console = false;
245 bool m_print_to_file = false;
246
252
253 fs::path m_file_path;
254 std::atomic<bool> m_reopen_file{false};
255
257 void LogPrintStr(std::string_view str, SourceLocation&& source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit)
259
262 {
263 StdLockGuard scoped_lock(m_cs);
264 return m_buffering || m_print_to_console || m_print_to_file || !m_print_callbacks.empty();
265 }
266
268 std::list<std::function<void(const std::string&)>>::iterator PushBackCallback(std::function<void(const std::string&)> fun) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
269 {
270 StdLockGuard scoped_lock(m_cs);
271 m_print_callbacks.push_back(std::move(fun));
272 return --m_print_callbacks.end();
273 }
274
276 void DeleteCallback(std::list<std::function<void(const std::string&)>>::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
277 {
278 StdLockGuard scoped_lock(m_cs);
279 m_print_callbacks.erase(it);
280 }
281
283 {
284 StdLockGuard scoped_lock(m_cs);
285 return m_print_callbacks.size();
286 }
287
292
294 {
295 StdLockGuard scoped_lock(m_cs);
296 m_limiter = std::move(limiter);
297 }
298
306
307 void ShrinkDebugFile();
308
310 {
311 StdLockGuard scoped_lock(m_cs);
312 return m_category_log_levels;
313 }
314 void SetCategoryLogLevel(const std::unordered_map<LogFlags, Level>& levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
315 {
316 StdLockGuard scoped_lock(m_cs);
317 m_category_log_levels = levels;
318 }
319 void AddCategoryLogLevel(LogFlags category, Level level)
320 {
321 StdLockGuard scoped_lock(m_cs);
322 m_category_log_levels[category] = level;
323 }
324 bool SetCategoryLogLevel(std::string_view category_str, std::string_view level_str) EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
325
326 Level LogLevel() const { return m_log_level.load(); }
327 void SetLogLevel(Level level) { m_log_level = level; }
328 bool SetLogLevel(std::string_view level);
329
330 CategoryMask GetCategoryMask() const { return m_categories.load(); }
331
332 void EnableCategory(LogFlags flag);
333 bool EnableCategory(std::string_view str);
334 void DisableCategory(LogFlags flag);
335 bool DisableCategory(std::string_view str);
336
337 bool WillLogCategory(LogFlags category) const;
339
341 std::vector<LogCategory> LogCategoriesList() const;
343 std::string LogCategoriesString() const
344 {
345 return util::Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; });
346 };
347
349 std::string LogLevelsString() const;
350
352 static std::string LogLevelToStr(BCLog::Level level);
353
354 bool DefaultShrinkDebugFile() const;
355 };
356
357} // namespace BCLog
358
360
362static inline bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level level)
363{
364 return LogInstance().WillLogCategoryLevel(category, level);
365}
366
368bool GetLogCategory(BCLog::LogFlags& flag, std::string_view str);
369
370template <typename... Args>
371inline void LogPrintFormatInternal(SourceLocation&& source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
372{
373 if (LogInstance().Enabled()) {
374 std::string log_msg;
375 try {
376 log_msg = tfm::format(fmt, args...);
377 } catch (tinyformat::format_error& fmterr) {
378 log_msg = "Error \"" + std::string{fmterr.what()} + "\" while formatting log message: " + fmt.fmt;
379 }
380 LogInstance().LogPrintStr(log_msg, std::move(source_loc), flag, level, should_ratelimit);
381 }
382}
383
384// Allow __func__ to be used in any context without warnings:
385// NOLINTNEXTLINE(bugprone-lambda-function-name)
386#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
387
388// Log unconditionally. Uses basic rate limiting to mitigate disk filling attacks.
389// Be conservative when using functions that unconditionally log to debug.log!
390// It should not be the case that an inbound peer can fill up a user's storage
391// with debug.log entries.
392#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
393#define LogWarning(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__)
394#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__)
395
396// Use a macro instead of a function for conditional logging to prevent
397// evaluating arguments when logging for the category is not enabled.
398
399// Log by prefixing the output with the passed category name and severity level. This logs conditionally if
400// the category is allowed. No rate limiting is applied, because users specifying -debug are assumed to be
401// developers or power users who are aware that -debug may cause excessive disk usage due to logging.
402#define detail_LogIfCategoryAndLevelEnabled(category, level, ...) \
403 do { \
404 if (LogAcceptCategory((category), (level))) { \
405 bool rate_limit{level >= BCLog::Level::Info}; \
406 Assume(!rate_limit);/*Only called with the levels below*/ \
407 LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \
408 } \
409 } while (0)
410
411// Log conditionally, prefixing the output with the passed category name.
412#define LogDebug(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__)
413#define LogTrace(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Trace, __VA_ARGS__)
414
415#endif // BITCOIN_LOGGING_H
ArgsManager & args
Definition: bitcoind.cpp:277
Fixed window rate limiter for logging.
Definition: logging.h:137
static std::shared_ptr< LogRateLimiter > Create(SchedulerFunction &&scheduler_func, uint64_t max_bytes, std::chrono::seconds reset_window)
Definition: logging.cpp:379
std::function< void(std::function< void()>, std::chrono::milliseconds)> SchedulerFunction
Definition: logging.h:161
const uint64_t m_max_bytes
Maximum number of bytes logged per location per window.
Definition: logging.h:175
LogRateLimiter(uint64_t max_bytes, std::chrono::seconds reset_window)
Definition: logging.cpp:376
Status Consume(const SourceLocation &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:391
bool SuppressionsActive() const
Returns true if any log locations are currently being suppressed.
Definition: logging.h:192
const std::chrono::seconds m_reset_window
Interval after which the window is reset.
Definition: logging.h:177
Status
Suppression status of a source log location.
Definition: logging.h:179
std::unordered_map< SourceLocation, Stats, SourceLocationHasher, SourceLocationEqual > m_source_locations GUARDED_BY(m_mutex)
Stats for each source location that has attempted to log something.
void Reset() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Resets all usage to zero. Called periodically by the scheduler.
Definition: logging.cpp:555
std::atomic< bool > m_suppression_active
Whether any log locations are suppressed. Cached view on m_source_locations for performance reasons.
Definition: logging.h:157
static std::string LogLevelToStr(BCLog::Level level)
Returns the string representation of a log level.
Definition: logging.cpp:234
bool m_always_print_category_level
Definition: logging.h:251
size_t m_buffer_lines_discarded GUARDED_BY(m_cs)
Definition: logging.h:215
FILE *m_fileout GUARDED_BY(m_cs)
bool m_buffering GUARDED_BY(m_cs)
Buffer messages before logging can be started.
bool WillLogCategory(LogFlags category) const
Definition: logging.cpp:149
std::list< BufferedLog > m_msgs_before_open GUARDED_BY(m_cs)
std::atomic< CategoryMask > m_categories
Log categories bitfield.
Definition: logging.h:228
void FormatLogStrInPlace(std::string &str, LogFlags category, Level level, const SourceLocation &source_loc, std::string_view threadname, SystemClock::time_point now, std::chrono::seconds mocktime) const
Definition: logging.cpp:407
void LogPrintStr_(std::string_view str, SourceLocation &&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:431
std::string LogTimestampStr(SystemClock::time_point now, std::chrono::seconds mocktime) const
Definition: logging.cpp:300
size_t m_cur_buffer_memusage GUARDED_BY(m_cs)
Definition: logging.h:214
bool DefaultShrinkDebugFile() const
Definition: logging.cpp:167
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:250
void SetCategoryLogLevel(const std::unordered_map< LogFlags, Level > &levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:314
void SetLogLevel(Level level)
Definition: logging.h:327
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:225
Level LogLevel() const
Definition: logging.h:326
CategoryMask GetCategoryMask() const
Definition: logging.h:330
bool WillLogCategoryLevel(LogFlags category, Level level) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.cpp:154
fs::path m_file_path
Definition: logging.h:253
bool m_log_time_micros
Definition: logging.h:248
bool m_log_threadnames
Definition: logging.h:249
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:268
void SetRateLimiting(std::shared_ptr< LogRateLimiter > limiter) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:293
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Disable logging This offers a slight speedup and slightly smaller memory usage compared to leaving th...
Definition: logging.cpp:111
std::vector< LogCategory > LogCategoriesList() const
Returns a vector of the log categories in alphabetical order.
Definition: logging.cpp:278
bool StartLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Start logging (and flush all buffered messages)
Definition: logging.cpp:54
void EnableCategory(LogFlags flag)
Definition: logging.cpp:123
size_t m_max_buffer_memusage GUARDED_BY(m_cs)
Definition: logging.h:213
bool m_log_timestamps
Definition: logging.h:247
void DeleteCallback(std::list< std::function< void(const std::string &)> >::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Delete a connection.
Definition: logging.h:276
std::string GetLogPrefix(LogFlags category, Level level) const
Definition: logging.cpp:343
void DisconnectTestLogger() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Only for testing.
Definition: logging.cpp:98
void AddCategoryLogLevel(LogFlags category, Level level)
Definition: logging.h:319
std::string LogLevelsString() const
Returns a string with all user-selectable log levels.
Definition: logging.cpp:294
size_t NumConnections()
Definition: logging.h:282
std::atomic< bool > m_reopen_file
Definition: logging.h:254
void ShrinkDebugFile()
Definition: logging.cpp:514
bool m_print_to_file
Definition: logging.h:245
std::unordered_map< LogFlags, Level > CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Definition: logging.h:309
bool m_print_to_console
Definition: logging.h:244
void LogPrintStr(std::string_view str, SourceLocation &&source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Send a string to the log output.
Definition: logging.cpp:424
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:235
StdMutex m_cs
Definition: logging.h:208
bool Enabled() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Returns whether logs will be written to any output.
Definition: logging.h:261
std::string LogCategoriesString() const
Returns a string with the log categories in alphabetical order.
Definition: logging.h:343
void DisableCategory(LogFlags flag)
Definition: logging.cpp:136
General SipHash-2-4 implementation.
Definition: siphash.h:27
CSipHasher & Write(uint64_t data)
Hash a 64-bit integer worth of data.
Definition: siphash.cpp:24
Like std::source_location, but allowing to override the function name.
Definition: logging.h:42
SourceLocation(const char *func, std::source_location loc=std::source_location::current())
The func argument must be constructed from the C++11 func macro.
Definition: logging.h:47
std::string_view function_name_short() const
Definition: logging.h:53
std::string_view m_func
Definition: logging.h:56
std::source_location m_loc
Definition: logging.h:57
std::string_view file_name() const
Definition: logging.h:51
std::uint_least32_t line() const
Definition: logging.h:52
static const bool DEFAULT_LOGTIMESTAMPS
Definition: logging.h:32
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:220
static const bool DEFAULT_LOGIPS
Definition: logging.h:31
static const bool DEFAULT_LOGTHREADNAMES
Definition: logging.h:33
static bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level level)
Return true if log accepts specified category, at the specified level.
Definition: logging.h:362
BCLog::Logger & LogInstance()
Definition: logging.cpp:26
static const bool DEFAULT_LOGSOURCELOCATIONS
Definition: logging.h:34
bool fLogIPs
Definition: logging.cpp:47
void LogPrintFormatInternal(SourceLocation &&source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
Definition: logging.h:371
static const bool DEFAULT_LOGTIMEMICROS
Definition: logging.h:30
const char *const DEFAULT_DEBUGLOGFILE
Definition: logging.cpp:23
static constexpr bool DEFAULT_LOGLEVELALWAYS
Definition: logging.h:35
constexpr auto RATELIMIT_WINDOW
Definition: logging.h:132
Level
Definition: logging.h:122
constexpr bool DEFAULT_LOGRATELIMIT
Definition: logging.h:133
constexpr uint64_t RATELIMIT_MAX_BYTES
Definition: logging.h:131
constexpr size_t DEFAULT_MAX_LOG_BUFFER
Definition: logging.h:130
uint64_t CategoryMask
Definition: logging.h:84
constexpr auto DEFAULT_LOG_LEVEL
Definition: logging.h:129
LogFlags
Definition: logging.h:85
@ ESTIMATEFEE
Definition: logging.h:95
@ TXRECONCILIATION
Definition: logging.h:115
@ RAND
Definition: logging.h:100
@ BLOCKSTORAGE
Definition: logging.h:114
@ COINDB
Definition: logging.h:105
@ REINDEX
Definition: logging.h:98
@ TXPACKAGES
Definition: logging.h:117
@ WALLETDB
Definition: logging.h:93
@ PRIVBROADCAST
Definition: logging.h:119
@ SCAN
Definition: logging.h:116
@ ADDRMAN
Definition: logging.h:96
@ ALL
Definition: logging.h:120
@ RPC
Definition: logging.h:94
@ HTTP
Definition: logging.h:90
@ LEVELDB
Definition: logging.h:107
@ NONE
Definition: logging.h:86
@ VALIDATION
Definition: logging.h:108
@ MEMPOOLREJ
Definition: logging.h:103
@ PRUNE
Definition: logging.h:101
@ TOR
Definition: logging.h:88
@ LIBEVENT
Definition: logging.h:104
@ CMPCTBLOCK
Definition: logging.h:99
@ PROXY
Definition: logging.h:102
@ ZMQ
Definition: logging.h:92
@ IPC
Definition: logging.h:110
@ MEMPOOL
Definition: logging.h:89
@ SELECTCOINS
Definition: logging.h:97
@ I2P
Definition: logging.h:109
@ BENCH
Definition: logging.h:91
@ NET
Definition: logging.h:87
@ KERNEL
Definition: logging.h:118
@ QT
Definition: logging.h:106
void format(std::ostream &out, FormatStringCheck< sizeof...(Args)> fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1079
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
Definition: string.h:204
constexpr auto MakeUCharSpan(const V &v) -> decltype(UCharSpanCast(std::span{v}))
Like the std::span constructor, but for (const) unsigned char member types only.
Definition: span.h:111
Keeps track of an individual source location and how many available bytes are left for logging from i...
Definition: logging.h:140
uint64_t m_available_bytes
Remaining bytes.
Definition: logging.h:142
Stats(uint64_t max_bytes)
Definition: logging.h:146
bool Consume(uint64_t bytes)
Updates internal accounting and returns true if enough available_bytes were remaining.
Definition: logging.cpp:573
uint64_t m_dropped_bytes
Number of bytes that were consumed but didn't fit in the available bytes.
Definition: logging.h:144
std::chrono::seconds mocktime
Definition: logging.h:200
std::string threadname
Definition: logging.h:201
SystemClock::time_point now
Definition: logging.h:199
SourceLocation source_loc
Definition: logging.h:202
bool active
Definition: logging.h:80
std::string category
Definition: logging.h:79
bool operator()(const SourceLocation &lhs, const SourceLocation &rhs) const noexcept
Definition: logging.h:61
size_t operator()(const SourceLocation &s) const noexcept
Definition: logging.h:68
A wrapper for a compile-time partially validated format string.
Definition: string.h:92
#define LOCK(cs)
Definition: sync.h:259
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51