pyln: Add logging handler that passes records to lightningd #4101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is often pretty usefuk to use the builtin logging module to debug things,
including libraries that a plugin may use. This adds a simple
PluginLogHandler
that maps the python logging levels to thelightningd
logging levels, and formats the record in a way that it doesn't clutter up the
lightningd
logs (no duplicate timestamps and levels).This allow us to tweak the log level that is reported to
lightningd
simplyusing the following
Notice that in order for the logs to be displayed on the terminal or the
logfile, both the logging level in the plugin and the
--log-level
lightningd
is running need to be adjusted (the python logging level onlycontrols which messages get forwarded to
lightningd
, it does not have thepower to overrule
lightningd
about what to actually display).I chose
logging.INFO
as the default, since libraries have a tendency to spewout everything in
logging.DEBUG
mode