@@ -723,6 +723,47 @@ General Bitcoin Core
723
723
- * Explanation* : If the test suite is to be updated for a change, this has to
724
724
be done first.
725
725
726
+ Logging
727
+ -------
728
+
729
+ The macros ` LogInfo ` , ` LogDebug ` , ` LogTrace ` , ` LogWarning ` and ` LogError ` are available for
730
+ logging messages. They should be used as follows:
731
+
732
+ - ` LogDebug(BCLog::CATEGORY, fmt, params...) ` is what you want
733
+ most of the time, and it should be used for log messages that are
734
+ useful for debugging and can reasonably be enabled on a production
735
+ system (that has sufficient free storage space). They will be logged
736
+ if the program is started with ` -debug=category ` or ` -debug=1 ` .
737
+ Note that ` LogPrint(BCLog::CATEGORY, fmt, params...) ` is a deprecated
738
+ alias for ` LogDebug ` .
739
+
740
+ - ` LogInfo(fmt, params...) ` should only be used rarely, eg for startup
741
+ messages or for infrequent and important events such as a new block tip
742
+ being found or a new outbound connection being made. These log messages
743
+ are unconditional so care must be taken that they can't be used by an
744
+ attacker to fill up storage. Note that ` LogPrintf(fmt, params...) ` is
745
+ a deprecated alias for ` LogInfo ` .
746
+
747
+ - ` LogError(fmt, params...) ` should be used in place of ` LogInfo ` for
748
+ severe problems that require the node (or a subsystem) to shut down
749
+ entirely (eg, insufficient storage space).
750
+
751
+ - ` LogWarning(fmt, params...) ` should be used in place of ` LogInfo ` for
752
+ severe problems that the node admin should address, but are not
753
+ severe enough to warrant shutting down the node (eg, system time
754
+ appears to be wrong, unknown soft fork appears to have activated).
755
+
756
+ - `LogTrace(BCLog::CATEGORY, fmt, params...) should be used in place of
757
+ ` LogDebug ` for log messages that would be unusable on a production
758
+ system, eg due to being too noisy in normal use, or too resource
759
+ intensive to process. These will be logged if the startup
760
+ options ` -debug=category -loglevel=category:trace ` or `-debug=1
761
+ -loglevel=trace` are selected.
762
+
763
+ Note that the format strings and parameters of ` LogDebug ` and ` LogTrace `
764
+ are only evaluated if the logging category is enabled, so you must be
765
+ careful to avoid side-effects in those expressions.
766
+
726
767
Wallet
727
768
-------
728
769
@@ -891,7 +932,7 @@ Strings and formatting
891
932
`wcstoll`, `wcstombs`, `wcstoul`, `wcstoull`, `wcstoumax`, `wcswidth`,
892
933
`wcsxfrm`, `wctob`, `wctomb`, `wctrans`, `wctype`, `wcwidth`, `wprintf`
893
934
894
- - For `strprintf`, `LogPrint `, `LogPrintf` formatting characters don't need size specifiers.
935
+ - For `strprintf`, `LogInfo `, `LogDebug`, etc formatting characters don't need size specifiers.
895
936
896
937
- *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion.
897
938
@@ -903,7 +944,7 @@ Strings and formatting
903
944
904
945
- *Rationale*: Although this is guaranteed to be safe starting with C++11, `.data()` communicates the intent better.
905
946
906
- - Do not use it when passing strings to `tfm::format`, `strprintf`, `LogPrint[f]` .
947
+ - Do not use it when passing strings to `tfm::format`, `strprintf`, `LogInfo`, `LogDebug`, etc .
907
948
908
949
- *Rationale*: This is redundant. Tinyformat handles strings.
909
950
0 commit comments