projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ACL uses enums, some more tests, other stuff.
[python_utils.git]
/
logging_utils.py
diff --git
a/logging_utils.py
b/logging_utils.py
index a24f1c9fb520f37ad7c13ec423e65c08b86074ae..700bfabcf9b9bbba8b28ca199253de40296a6ccc 100644
(file)
--- a/
logging_utils.py
+++ b/
logging_utils.py
@@
-10,10
+10,10
@@
import os
import pytz
import sys
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 argparse_utils
import config
-import string_utils as su
-import thread_utils as tu
cfg = config.add_commandline_args(
f'Logging ({__file__})',
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']:
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
print(*args, **kwargs)
else:
pass
@@
-258,6
+259,7
@@
class OutputSink(object):
self.destination_bitv = destination_bitv
def print(self, *args, **kwargs):
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):
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()")
raise TypeError("sep must be None or a string")
if kwargs:
raise TypeError("invalid keyword arguments to print()")
- buf = s
u.s
printf(*args, end="", sep=sep)
+ buf = sprintf(*args, end="", sep=sep)
if sep is None:
sep = " "
if end is None:
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()
if self.destination_bitv & self.FILENAME and self.f is not None:
self.f.write(buf.encode('utf-8'))
self.f.flush()
- buf = s
u.s
trip_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)
if self.logger is not None:
if self.destination_bitv & self.LOG_DEBUG:
self.logger.debug(buf)