Problem: Currently it is difficult to enable trace logging.
The -loglevel=trace setting works, but does nothing by default and needs to be combined with -debug settings to have an effect.
Additionally, it is not possible to switch between debug and trace logging at runtime without restarting the node. These problems make trace logging less useful than it could be, effectively make existing trace logs undiscoverable, and making it not worthwhile to add new tracing.
Solution: Fix these issues by allowing the -loglevel option to work without an accompanying -debug option, and by adding a matching loglevel RPC that allows log levels to be configured at runtime.
Usage examples:
bitcoin rpc loglevel # See current log levels
bitcoin rpc loglevel trace # Set global level to -loglevel=trace
bitcoin rpc loglevel debug # Set global level to -loglevel=debug
bitcoin rpc loglevel info # Set global level to -loglevel=info
bitcoin rpc loglevel libevent=info # Set category level to -loglevel=libevent:info
bitcoin rpc loglevel trace net=debug libevent=info # Set global & category levels to -loglevel=trace,net:debug,libevent:info
Compatibility: This PR is backwards compatible and doesn't change the -debug and -debugexclude options (which become synonyms for -loglevel=debug and -loglevel=info, respectively). The logging RPC is also mostly unchanged, except now it validates category names before updating log levels, instead of failing with half-applied changes. Also the logging RPC now only toggles between info and debug levels instead of trying to remember previously assigned levels, which was needlessly confusing.