Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,36 @@
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):
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ kornia>=0.7.1
spandrel
soundfile
av
rich