Skip to content

logging: threshold log level

Overview: This PR allows logs below the threshold severity level to be ignored (a continuation of #24464).

Notable changes:

  • Deduplicate identical code in LogCategoryToStr and LogCategories (addresses https://github.com/bitcoin/bitcoin/pull/24464#discussion_r880665834)
  • Threshold log level:
    • Introduce a global threshold log level that will allow the logger to ignore logs that are below the threshold level (defaults to Levels::info)
      • User can configure this with -loglevel=<level> (ie: -loglevel=warning)
    • Introduce a category-specific threshold log level that overrides the global threshold log level. Category-specific log level will only apply to the category supplied in the configuration
      • User can configure this with -loglevel=<category>:<level> (ie: -loglevel=net:warning)

Testing:

Global log level:

# global log level = info (default)
$ ./src/bitcoind -signet
$ grep -o "net:debug" ~/.bitcoin/signet/debug.log | wc -l
0

# global log level = debug
$ ./src/bitcoind -signet -loglevel=debug
$ grep -o "net:debug" ~/.bitcoin/signet/debug.log | wc -l
4

Merge request reports

Loading