mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 20:35:17 +02:00
Merge bitcoin/bitcoin#30386: Early logging improvements
b4dd7ab43elogging: use std::string_view (Anthony Towns)558df5c733logging: Apply formatting to early log messages (Anthony Towns)6cf9b34440logging: Limit early logging buffer (Anthony Towns)0b1960f1b2logging: Add DisableLogging() (Anthony Towns)6bbc2dd6c5logging: Add thread safety annotations (Anthony Towns) Pull request description: In order to cope gracefully with `Log*()` calls that are invoked prior to logging being fully configured (indicated by calling `StartLogging()` we buffer early log messages in `m_msgs_before_open`. This has a couple of minor issues: * if there are many such log messages the buffer can become arbitrarily large; this can be a problem for users of libkernel that might not wish to worry about logging at all, and as a result never invoke `StartLogging()` * early log messages are formatted before the formatting options are configured, leading to inconsistent output Fix those issues by buffering the log info prior to formatting it, and setting a limit on the size of the buffer (dropping the oldest lines, and reporting the number of lines skipped). Also adds some thread safety annotations, and the ability to invoke `LogInstance().DisableLogging()` if you want to disable logging entirely, for a minor efficiency improvement. ACKs for top commit: maflcko: re-ACKb4dd7ab43e🕴 ryanofsky: Code review ACKb4dd7ab43eTheCharlatan: Nice, ACKb4dd7ab43eTree-SHA512: 966660181276939225a9f776de6ee0665e44577d2ee9cc76b06c8937297217482e6e426bdc5772d1ce533a0ba093a8556b6a50857d4c876ad8923e432a200440
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <core_io.h>
|
||||
#include <logging.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/caches.h>
|
||||
#include <node/chainstate.h>
|
||||
@@ -41,6 +42,12 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// We do not enable logging for this app, so explicitly disable it.
|
||||
// To enable logging instead, replace with:
|
||||
// LogInstance().m_print_to_console = true;
|
||||
// LogInstance().StartLogging();
|
||||
LogInstance().DisableLogging();
|
||||
|
||||
// SETUP: Argument parsing and handling
|
||||
if (argc != 2) {
|
||||
std::cerr
|
||||
|
||||
Reference in New Issue
Block a user