Created
March 8, 2023 03:17
-
-
Save sakku116/a7d5fc851452f141a297abb6e77a4b6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from uvicorn.config import LOGGING_CONFIG | |
import logging | |
# custom logging | |
LOGGING_CONFIG["loggers"]["uvicorn.custom"] = { | |
"handlers": ["custom"], | |
"level": "INFO", | |
"propagate": False | |
} | |
LOGGING_CONFIG["handlers"]["custom"] = { | |
"formatter": "custom", | |
"class": "logging.StreamHandler", | |
"stream": "ext://sys.stdout", | |
} | |
LOGGING_CONFIG["formatters"]["custom"] = { | |
"()": "uvicorn.logging.ColourizedFormatter", | |
"fmt": "%(asctime)s %(levelprefix)s [%(filename)s:%(lineno)d] - %(message)s", | |
"datefmt": "%Y-%m-%d %H:%M:%S" | |
} | |
# call the logger | |
logger = logging.getLogger("uvicorn.custom") | |
logger.info("hello world) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment