mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-04 04:54:47 +01:00
556725c5ff
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 the `lightningd` 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` simply using the following ```python3 import logging logging.basicConfig(level=logging.DEBUG) ``` 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 only controls which messages get forwarded to `lightningd`, it does not have the power to overrule `lightningd` about what to actually display). I chose `logging.INFO` as the default, since libraries have a tendency to spew out everything in `logging.DEBUG` mode Changelog-Added: pyln: Plugins have been integrated with the `logging` module for easier debugging and error reporting. |
||
---|---|---|
.. | ||
__init__.py | ||
lightning.py | ||
plugin.py |