Skip to content

Commit

Permalink
update uvicorn logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarkeM committed Apr 23, 2024
1 parent b2705d9 commit b902bd4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import redis.asyncio as redis
import json
from quart import Quart, request, jsonify
from uvicorn.config import LOGGING_CONFIG

# Development Configurations
DEV_CONFIG = {
Expand All @@ -13,7 +14,7 @@
}

is_development = os.environ.get('QUART_ENV') == 'development'

TIME_FORMAT = '%d/%m/%Y %H:%M:%S'

class LogColors:
DEBUG = '\033[92m' # GREEN
Expand Down Expand Up @@ -56,7 +57,7 @@ def format(self, record):

# Setup logging
log_format = "%(levelname)s %(asctime)s %(message)s"
formatter = ColoredFormatter(log_format, datefmt='%d/%m/%Y %H:%M:%S')
formatter = ColoredFormatter(log_format, datefmt=TIME_FORMAT)

console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
Expand All @@ -73,6 +74,10 @@ def format(self, record):
logger.setLevel(logging.INFO)

logging.basicConfig(level=logging.INFO, handlers=[console_handler])
LOGGING_CONFIG['formatters']['default']['()'] = 'app.app.ColoredFormatter'
LOGGING_CONFIG['formatters']['default']['datefmt'] = TIME_FORMAT
LOGGING_CONFIG['formatters']['access']['()'] = 'app.app.ColoredFormatter'
LOGGING_CONFIG['formatters']['access']['datefmt'] = TIME_FORMAT

app = Quart(__name__)
current_token_idx = 0
Expand Down

0 comments on commit b902bd4

Please sign in to comment.