Compare commits

...

3 Commits

Author SHA1 Message Date
John D. Pope
7849317491
Merge a2622cedcb into 98bdca4cb2 2025-04-10 17:57:21 +07:00
John D. Pope
a2622cedcb
Update requirements.txt 2025-04-07 21:53:33 +10:00
John D. Pope
25664388b3
Update logger.py 2025-04-07 21:52:52 +10:00
2 changed files with 32 additions and 0 deletions

View File

@ -4,11 +4,36 @@ import io
import logging
import sys
import threading
from rich.traceback import install
from rich.console import Console
from rich.theme import Theme
from rich.logging import RichHandler
logs = None
stdout_interceptor = None
stderr_interceptor = None
from rich.traceback import install
# Enable rich tracebacks globally
install()
# Configure rich console
console = Console(force_terminal=True)
# Set up handler
rich_handler = RichHandler(console=console, rich_tracebacks=True, markup=True)
# file_handler = logging.FileHandler("project.log") # Log to a file
# file_handler.setLevel(log_level)
from rich.traceback import install
# Enable rich tracebacks globally
install()
class LogInterceptor(io.TextIOWrapper):
def __init__(self, stream, *args, **kwargs):
@ -56,6 +81,12 @@ def setup_logger(log_level: str = 'INFO', capacity: int = 300, use_stdout: bool
if logs:
return
logging.basicConfig(
level=log_level,
format="%(message)s",
datefmt="[%X]",
handlers=[rich_handler] #file_handler
)
# Override output streams and log to buffer
logs = deque(maxlen=capacity)

View File

@ -22,3 +22,4 @@ kornia>=0.7.1
spandrel
soundfile
av
rich