Fix audit log timezone to UTC+8
This commit is contained in:
@@ -13,8 +13,11 @@ import httpx
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import jwt
|
import jwt
|
||||||
|
from datetime import datetime, timezone, timedelta
|
||||||
from config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, CORS_ORIGINS, SECRET_KEY, ALGORITHM, VOLUME_ROOT
|
from config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, CORS_ORIGINS, SECRET_KEY, ALGORITHM, VOLUME_ROOT
|
||||||
|
|
||||||
|
_tz_cst = timezone(timedelta(hours=8))
|
||||||
|
|
||||||
limiter = Limiter(key_func=get_remote_address)
|
limiter = Limiter(key_func=get_remote_address)
|
||||||
app = FastAPI(title="NAS Dashboard")
|
app = FastAPI(title="NAS Dashboard")
|
||||||
app.state.limiter = limiter
|
app.state.limiter = limiter
|
||||||
@@ -67,7 +70,7 @@ async def audit_log(request: Request, call_next):
|
|||||||
pass
|
pass
|
||||||
_audit_logger.info(
|
_audit_logger.info(
|
||||||
"%s %s %s %s %s %d %dms",
|
"%s %s %s %s %s %d %dms",
|
||||||
time.strftime("%Y-%m-%dT%H:%M:%S"), request.client.host, user,
|
datetime.now(_tz_cst).strftime("%Y-%m-%dT%H:%M:%S"), request.client.host, user,
|
||||||
request.method, request.url.path, response.status_code, duration,
|
request.method, request.url.path, response.status_code, duration,
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user