mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 02:13:41 +03:00
Move GUI/CLI conditional into get_plugin_logger()
It's cleaner here than in the calling plug.py code.
This commit is contained in:
parent
fa326ad3d3
commit
7750bbdf4a
@ -123,7 +123,7 @@ class Logger:
|
|||||||
return self.logger_channel
|
return self.logger_channel
|
||||||
|
|
||||||
|
|
||||||
def get_plugin_logger(name: str, loglevel: int = _default_loglevel) -> logging.Logger:
|
def get_plugin_logger(plugin_name: str, loglevel: int = _default_loglevel) -> logging.Logger:
|
||||||
"""
|
"""
|
||||||
Return a logger suitable for a plugin.
|
Return a logger suitable for a plugin.
|
||||||
|
|
||||||
@ -144,7 +144,12 @@ def get_plugin_logger(name: str, loglevel: int = _default_loglevel) -> logging.L
|
|||||||
:param loglevel: Optional logLevel for this Logger.
|
:param loglevel: Optional logLevel for this Logger.
|
||||||
:return: logging.Logger instance, all set up.
|
:return: logging.Logger instance, all set up.
|
||||||
"""
|
"""
|
||||||
plugin_logger = logging.getLogger(name)
|
if not os.getenv('EDMC_NO_UI'):
|
||||||
|
base_logger_name = appname
|
||||||
|
else:
|
||||||
|
base_logger_name = appcmdname
|
||||||
|
|
||||||
|
plugin_logger = logging.getLogger(f'{base_logger_name}.{plugin_name}')
|
||||||
plugin_logger.setLevel(loglevel)
|
plugin_logger.setLevel(loglevel)
|
||||||
|
|
||||||
plugin_logger.addFilter(EDMCContextFilter())
|
plugin_logger.addFilter(EDMCContextFilter())
|
||||||
|
6
plug.py
6
plug.py
@ -203,12 +203,8 @@ def load_plugins(master):
|
|||||||
# Create a logger for this 'found' plugin. Must be before the
|
# Create a logger for this 'found' plugin. Must be before the
|
||||||
# load.py is loaded.
|
# load.py is loaded.
|
||||||
import EDMCLogging
|
import EDMCLogging
|
||||||
if not os.getenv('EDMC_NO_UI'):
|
|
||||||
base_logger_name = appname
|
|
||||||
else:
|
|
||||||
base_logger_name = appcmdname
|
|
||||||
plugin_logger = EDMCLogging.get_plugin_logger(f'{base_logger_name}.{name}')
|
|
||||||
|
|
||||||
|
plugin_logger = EDMCLogging.get_plugin_logger(name)
|
||||||
found.append(Plugin(name, os.path.join(config.plugin_dir, name, 'load.py'), plugin_logger))
|
found.append(Plugin(name, os.path.join(config.plugin_dir, name, 'load.py'), plugin_logger))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f'Failure loading found Plugin "{name}"')
|
logger.exception(f'Failure loading found Plugin "{name}"')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user