Overview: This PR introduces a new macro, LogPrintLevel, that allows developers to add logs with the severity level. Additionally, it will also print the log category if it is specified.
Sample log:
02022-03-04T16:41:15Z [opencon] [net:debug] trying connection XX.XX.XXX.XXX:YYYYY lastseen=2.7hrs
Motivation: This feature was suggested in #20576 and I believe that it will bring the following benefits:
- Allow for easier filtering of logs in debug.log
- Can be extended to allow users to select the minimum level of logs they would like to view (not in the scope of this PR)
Details:
- New log format. ... [category:level].... ie:- Do not print category if category == NONE
- Do not print level if level == NONE
- If category == NONEandlevel == NONE, do not print any fields (current behaviour)
 
- Do not print category if 
- Previous logging functions:
- LogPrintf: no changes in log as it calls- LogPrintf_with- category = NONEand- level = NONE
- LogPrint: prints additional- [category]field as it calls- LogPrintf_with- category = categoryand- level = NONE
 
- net.cpp: As a proof of concept, updated logs with obvious severity (ie prefixed with- Warning/Error:..) to use the new logging with severity.
Testing:
- 
Compiling and running bitcoindwith this PR should instantly display logs with the category name (ienet/tor/...)
- 
Grepping for net:debugindebug.logshould display the updated logs with severity level:0$ grep "net:debug" debug.log 1 22022-03-04T16:41:15Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs 32022-03-04T16:41:16Z [opencon] [net:debug] trying connection XXX:YYY lastseen=16.9hrs 42022-03-04T16:41:17Z [opencon] [net:debug] trying connection XXX:YYY lastseen=93.2hrs 52022-03-04T16:41:18Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs