From 48c37987b271aa7ffe306e38459b4db38d0fc413 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Wed, 18 Jan 2023 14:23:25 +0100 Subject: [PATCH] fixed logging and added current timezone info --- app/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 204a55a..76a42b2 100644 --- a/app/main.py +++ b/app/main.py @@ -22,9 +22,10 @@ from sqlalchemy.orm import sessionmaker from util import load_key, load_file from orm import Origin, Lease, init as db_init, migrate -logger = logging.getLogger() load_dotenv('../version.env') +TZ = datetime.now().astimezone().tzinfo + VERSION, COMMIT, DEBUG = env('VERSION', 'unknown'), env('COMMIT', 'unknown'), bool(env('DEBUG', False)) config = dict(openapi_url='/-/openapi.json', docs_url='/-/docs', redoc_url='/-/redoc') @@ -58,6 +59,8 @@ app.add_middleware( allow_headers=['*'], ) +logging.basicConfig() +logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG if DEBUG else logging.INFO) @@ -97,6 +100,7 @@ async def _config(): 'LEASE_EXPIRE_DELTA': str(LEASE_EXPIRE_DELTA), 'LEASE_RENEWAL_PERIOD': str(LEASE_RENEWAL_PERIOD), 'CORS_ORIGINS': str(CORS_ORIGINS), + 'TZ': str(TZ), }) @@ -529,6 +533,11 @@ async def leasing_v1_lessor_shutdown(request: Request): return JSONr(response) +@app.on_event('startup') +async def app_on_startup(): + logger.info(f'Using timezone: {str(TZ)}. Make sure this is correct and match your clients!') + + if __name__ == '__main__': import uvicorn