Move the logging wrapper code into a helper function
@@ -95,6 +95,12 @@ class BeetsPlugin(object):
"""
return ()
+ def _set_stage_log_level(self, stages):
+ """Adjust all the stages in `stages` to WARNING logging level.
+ """
+ return [self._set_log_level_and_params(logging.WARNING, stage)
+ for stage in stages]
+
def get_early_import_stages(self):
"""Return a list of functions that should be called as importer
pipelines stages early in the pipeline.
@@ -103,8 +109,7 @@ class BeetsPlugin(object):
`self.early_import_stages`. Wrapping provides some bookkeeping for the
plugin: specifically, the logging level is adjusted to WARNING.
"""
- return [self._set_log_level_and_params(logging.WARNING, import_stage)
- for import_stage in self.early_import_stages]
+ return self._set_stage_log_level(self.early_import_stages)
def get_import_stages(self):
"""Return a list of functions that should be called as importer
@@ -114,8 +119,7 @@ class BeetsPlugin(object):
`self.import_stages`. Wrapping provides some bookkeeping for the
plugin: specifically, the logging level is adjusted to WARNING.
"""
- return [self._set_log_level_and_params(logging.WARNING, import_stage)
- for import_stage in self.import_stages]
+ return self._set_stage_log_level(self.import_stages)
def _set_log_level_and_params(self, base_log_level, func):
"""Wrap `func` to temporarily set this plugin's logger level to
