Files
SillyTavern-extras/modules/utils.py
2023-08-19 01:26:05 +02:00

15 lines
342 B
Python

from contextlib import contextmanager
import sys
@contextmanager
def silence_log():
old_stdout = sys.stdout
old_stderr = sys.stderr
try:
with open(os.devnull, "w") as new_target:
sys.stdout = new_target
yield new_target
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr