mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
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.
This commit is contained in:
parent
7c9b8861fc
commit
a19fd3cbf6
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user