X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=logging_utils.py;h=700bfabcf9b9bbba8b28ca199253de40296a6ccc;hb=09e6d10face80d98a4578ff54192b5c8bec007d7;hp=a24f1c9fb520f37ad7c13ec423e65c08b86074ae;hpb=3bc4daf1edc121cd633429187392227f2fa61885;p=python_utils.git diff --git a/logging_utils.py b/logging_utils.py index a24f1c9..700bfab 100644 --- a/logging_utils.py +++ b/logging_utils.py @@ -10,10 +10,10 @@ import os import pytz import sys +# This module is commonly used by others in here and should avoid +# taking any unnecessary dependencies back on them. import argparse_utils import config -import string_utils as su -import thread_utils as tu cfg = config.add_commandline_args( f'Logging ({__file__})', @@ -199,7 +199,8 @@ def get_logger(name: str = ""): def tprint(*args, **kwargs) -> None: if config.config['logging_debug_threads']: - print(f'{tu.current_thread_id()}', end="") + from thread_utils import current_thread_id + print(f'{current_thread_id()}', end="") print(*args, **kwargs) else: pass @@ -258,6 +259,7 @@ class OutputSink(object): self.destination_bitv = destination_bitv def print(self, *args, **kwargs): + from string_utils import sprintf, strip_escape_sequences end = kwargs.pop("end", None) if end is not None: if not isinstance(end, str): @@ -268,7 +270,7 @@ class OutputSink(object): raise TypeError("sep must be None or a string") if kwargs: raise TypeError("invalid keyword arguments to print()") - buf = su.sprintf(*args, end="", sep=sep) + buf = sprintf(*args, end="", sep=sep) if sep is None: sep = " " if end is None: @@ -282,7 +284,7 @@ class OutputSink(object): if self.destination_bitv & self.FILENAME and self.f is not None: self.f.write(buf.encode('utf-8')) self.f.flush() - buf = su.strip_escape_sequences(buf) + buf = strip_escape_sequences(buf) if self.logger is not None: if self.destination_bitv & self.LOG_DEBUG: self.logger.debug(buf)