From: Zack Cerza Date: Thu, 11 Jul 2024 16:05:48 +0000 (-0600) Subject: Move LoggerFile to teuthology.util X-Git-Tag: 1.2.0~17^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf8d39427b969ae2382caf4e6bd1e370cade49a9;p=teuthology.git Move LoggerFile to teuthology.util Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index d27137d12..29d1170d1 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -14,30 +14,12 @@ from teuthology import repo_utils from teuthology.config import config as teuth_config from teuthology.exceptions import CommandFailedError, AnsibleFailedError from teuthology.job_status import set_status - from teuthology.task import Task +from teuthology.util.loggerfile import LoggerFile log = logging.getLogger(__name__) -class LoggerFile(object): - """ - A thin wrapper around a logging.Logger instance that provides a file-like - interface. - - Used by Ansible.execute_playbook() when it calls pexpect.run() - """ - def __init__(self, logger, level): - self.logger = logger - self.level = level - - def write(self, string): - self.logger.log(self.level, string.decode('utf-8', 'ignore')) - - def flush(self): - pass - - class FailureAnalyzer: def analyze(self, failure_log): failure_obj = yaml.safe_load(failure_log) diff --git a/teuthology/task/cephmetrics.py b/teuthology/task/cephmetrics.py index fee4ad6b6..813d266ad 100644 --- a/teuthology/task/cephmetrics.py +++ b/teuthology/task/cephmetrics.py @@ -5,8 +5,9 @@ import time from teuthology.config import config as teuth_config from teuthology.exceptions import CommandFailedError +from teuthology.task.ansible import Ansible +from teuthology.util.loggerfile import LoggerFile -from teuthology.task.ansible import Ansible, LoggerFile log = logging.getLogger(__name__) diff --git a/teuthology/util/loggerfile.py b/teuthology/util/loggerfile.py new file mode 100644 index 000000000..3dd786258 --- /dev/null +++ b/teuthology/util/loggerfile.py @@ -0,0 +1,19 @@ +import logging + +class LoggerFile(object): + """ + A thin wrapper around a logging.Logger instance that provides a file-like + interface. + + Used by Ansible.execute_playbook() when it calls pexpect.run() + """ + def __init__(self, logger: logging.Logger, level: int): + self.logger = logger + self.level = level + + def write(self, string): + self.logger.log(self.level, string.decode('utf-8', 'ignore')) + + def flush(self): + pass +