From 5b5da7c3924dadd4f8d01656f3a3c2bc6ed4b554 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Mon, 4 Nov 2019 16:18:40 +0000 Subject: [PATCH] module/cgroups: log to the class' logger All classes in the module have a logger. Avoid using the root logger and use the class' logger. --- devlib/module/cgroups.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py index 71885a6..3651755 100644 --- a/devlib/module/cgroups.py +++ b/devlib/module/cgroups.py @@ -158,16 +158,16 @@ class Controller(object): raise ValueError('wrong type for "exclude" parameter, ' 'it must be a str or a list') - logging.debug('Moving all tasks into %s', dest) + self.logger.debug('Moving all tasks into %s', dest) # Build list of tasks to exclude grep_filters = '' for comm in exclude: grep_filters += '-e {} '.format(comm) - logging.debug(' using grep filter: %s', grep_filters) + self.logger.debug(' using grep filter: %s', grep_filters) if grep_filters != '': - logging.debug(' excluding tasks which name matches:') - logging.debug(' %s', ', '.join(exclude)) + self.logger.debug(' excluding tasks which name matches:') + self.logger.debug(' %s', ', '.join(exclude)) for cgroup in self._cgroups: if cgroup != dest: @@ -288,10 +288,8 @@ class CGroup(object): def get(self): conf = {} - logging.debug('Reading %s attributes from:', - self.controller.kind) - logging.debug(' %s', - self.directory) + self.logger.debug('Reading %s attributes from:', self.controller.kind) + self.logger.debug(' %s', self.directory) output = self.target._execute_util( # pylint: disable=protected-access 'cgroups_get_attributes {} {}'.format( self.directory, self.controller.kind), @@ -330,7 +328,7 @@ class CGroup(object): def get_tasks(self): task_ids = self.target.read_value(self.tasks_file).split() - logging.debug('Tasks: %s', task_ids) + self.logger.debug('Tasks: %s', task_ids) return list(map(int, task_ids)) def add_task(self, tid):