From a19fd3cbf6d7956ea730e6953934544e0ff792aa Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 18 Sep 2020 13:07:44 +0100 Subject: [PATCH] PLUGINS.md: Emphasise the correct way to get a logger. A_D had accidentally used 'ClickCounter' for this when their folder name was 'click_counter'. This lead to using a very bare `logger` which still used our defined format leading to things blowing up when there was no adapter to handle `qualname` format string. --- PLUGINS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PLUGINS.md b/PLUGINS.md index c391a3ab..3eba7d06 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -82,6 +82,8 @@ plugin_name = os.path.basename(os.path.dirname(__file__)) # A Logger is used per 'found' plugin to make it easy to include the plugin's # folder name in the logging output format. +# NB: plugin_name here *must* be the plugin's folder name as per the preceding +# code, else the logger won't be properly set up. logger = logging.getLogger(f'{appname}.{plugin_name}') # If the Logger has handlers then it was already set up by the core code, else @@ -98,6 +100,13 @@ if not logger.hasHandlers(): logger.addHandler(logger_channel) ``` +Note the admonishment about `plugin_name` being the folder name of your plugin. +It can't be anything else (such as a different string returned from +`plugin_start3()`) because the code in plug.py that sets up the logger uses +exactly the folder name. Our custom `qualname` and `class` formatters won't +work with a 'bare' logger, and will cause your code to throw exceptions if +you're not using our supplied logger. + If running with 4.1.0-beta1 or later of EDMC the logging setup happens in the core code and will include the extra logfile destinations. If your plugin is run under a pre-4.1.0 version of EDMC then the above will set up