Refactor utils

- Move statsd client into it's own module
- Move all logging functions into their own module
- Move all config functions into their own module
- Move all helper functions into their own module

Partial-Bug: #2015274
Change-Id: Ic4b5005e3efffa8dba17d91a41e46d5c68533f9a
This commit is contained in:
Shreeya Deshpande
2024-04-02 14:33:29 -07:00
committed by Tim Burke
parent 6387949a54
commit bc3a59bdd3
13 changed files with 1869 additions and 1703 deletions

@ -19,7 +19,7 @@ import sys
from collections import defaultdict
from swift.common import utils
from swift.common import utils, statsd_client
from swift.common.utils import NOTICE
@ -29,7 +29,7 @@ class WARN_DEPRECATED(Exception):
print(self.msg)
class FakeStatsdClient(utils.StatsdClient):
class FakeStatsdClient(statsd_client.StatsdClient):
def __init__(self, host, port, base_prefix='', tail_prefix='',
default_sample_rate=1, sample_rate_factor=1, logger=None):
super(FakeStatsdClient, self).__init__(
@ -313,8 +313,8 @@ def capture_logger(conf, *args, **kwargs):
accessor methods (e.g. get_lines_for_level) directly on the logger
instance.
"""
with mock.patch('swift.common.utils.LogAdapter', CaptureLogAdapter):
log_adapter = utils.get_logger(conf, *args, **kwargs)
with mock.patch('swift.common.utils.logs.LogAdapter', CaptureLogAdapter):
log_adapter = utils.logs.get_logger(conf, *args, **kwargs)
log_adapter.start_capture()
try:
yield log_adapter