-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Log: Add debug log category tag #21102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Things to consider: If on by default this will likely break some existing log parsing tools. Our wallet logs it's name using 2021-02-08T02:55:14Z [test] Wallet File Version = 169900
2021-02-08T02:55:14Z [test] Keys: 2018 plaintext, 0 encrypted, 2018 w/ metadata, 2018 total. Unknown wallet records: 0 With this change, wallet names can be misinterpreted as a logging category.
I think those changes should just be part of this PR. For anyone running with 2021-02-08T02:34:43Z [init] [http] Starting HTTP server
2021-02-08T02:34:43Z [init] HTTP: starting 4 worker threads
2021-02-08T02:34:43Z [http] [http] Entering http event loop
...
2021-02-08T02:34:54Z [torcontrol] [tor] tor: Error connecting to Tor control socket
2021-02-08T02:34:54Z [torcontrol] [tor] tor: Not connected to Tor control port 127.0.0.1:9051, trying to reconnect |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Done, added a scripted-diff commit. |
Thanks, I was not aware of
and with
I would be fine with that. Offtopic of this PR, just an idea: |
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/(BCLog::(NET|TOR|MEMPOOL|HTTP|BENCH|ZMQ|WALLETDB|RPC|ESTIMATEFEE|ADDRMAN|SELECTCOINS|REINDEX|CMPCTBLOCK|RAND|PRUNE|PROXY|MEMPOOLREJ|LIBEVENT|COINDB|QT|LEVELDB|VALIDATION)\s*,\s*")\s*\2\s*:\s*(.*)/\1\3/gi' $(git ls-files src/) -END VERIFY SCRIPT-
Log looks now like this with logthreadnames=1:
|
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
Closing due to need for rebase and no further feedback. |
Fixes #21058
As the
LogPrint
macro takes the debug log category as parameter, I think it would be nice to have that debug log category also shown together with the according debug log message, to have clear transparency what debug message belongs to what debug category.In the past, people inserted the same debug log category name in the message itself, e.g.
torcontrol.cpp: LogPrint(BCLog::TOR, "tor: SAFECOOKIE authentication challenge successful\n");
With this patch,
this would be obsolete, and I would be willing to create a follow-up PR to cleanup that redundancythose then-redundant in-message categories are removed.Here is a log example how the log looks with this patch and
debug=1
:I tested also with setting
debug=addrman
and it works, only debug log messages of categoryaddrman
are logged then, with the prefix.I think this is a step for the better and there is no drawback. I think there should be a better logging with pairing of log category and log level (e.g. like in Tor log), but that should be out of the scope of this PR.
I have read the developer notes, and because of section "Source code organization" I extra included the
#include <map>
inlogging.cpp
allthough it was not needed to successfully compile.Unfortunately, I am no C++ expert and I guess there are chances that the places/scope of the definitions may be not optimal.
Any help for doing better is appreciated.
I saw the need to clone the function
LogCategoryPrintf
because I had not seen a way to change__VA_ARGS__
to insert the log category string in the beginning of the first (format string) parameter.I have allowed edits by maintainers, too, your are welcome to edit.