Skip to content

Instantly share code, notes, and snippets.

@Willy-JL
Willy-JL / logger.py
Last active May 16, 2022 18:41
Log console output and input to file without custom color codes (supports colorama)
from contextlib import contextmanager
import sys
import re
import os
# Fix missing streams
for stream in ("stdout", "stderr", "stdin"):
if getattr(sys, stream) is None:
setattr(sys, stream, open(os.devnull, "w+"))