This commit is contained in:
John D. Pope 2025-04-11 14:19:40 +03:00 committed by GitHub
commit 463fb63330
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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