Skip to content

Commit 57087b8

Browse files
surajitsurajit
authored andcommitted
modify log
1 parent 02025b0 commit 57087b8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logger/log.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import logging
22
import os
3+
import uuid
34
from logging.handlers import RotatingFileHandler
45
from functools import wraps
56

7+
from aws.services.dynamo_db.logs import create_log
68
from settings import LOG_FILE_DIR
79
from settings import LOG_FILE_NAME
810

@@ -39,6 +41,7 @@ async def wrapper(*args, **kwargs):
3941
try:
4042
request = kwargs.get("request")
4143
url = request.url
44+
client = request.client.host
4245
method = request.method
4346
message = dict(
4447
url=str(url),
@@ -51,6 +54,12 @@ async def wrapper(*args, **kwargs):
5154
json_data = await request.json()
5255
message["data"] = [json_data]
5356
logger.debug(message)
57+
data = dict(
58+
log_id=str(uuid.uuid4()),
59+
request_ip=client,
60+
message=message
61+
)
62+
await create_log(data)
5463
except Exception as exc:
5564
logger.exception(f"Exception occurred {exc}")
5665
pass

0 commit comments

Comments
 (0)