правка словаря отправки данных и логирования
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import config
|
import config
|
||||||
import json
|
import json
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
@@ -6,10 +8,13 @@ import aiohttp
|
|||||||
|
|
||||||
|
|
||||||
def loggingDict(title: str, data: dict) -> None:
|
def loggingDict(title: str, data: dict) -> None:
|
||||||
logging.info(
|
call_id = data.get("call_session_id", "None")
|
||||||
f"{title}: %s",
|
today = datetime.now().strftime("%Y-%m-%d")
|
||||||
json.dumps(data, indent=4, ensure_ascii=False).encode("utf-8").decode("utf-8"),
|
file_name = f"log/post/{today}/{call_id}.log"
|
||||||
)
|
if not os.path.exists(f"log/post/{today}"):
|
||||||
|
os.makedirs(f"log/post/{today}")
|
||||||
|
with open(file_name, "a") as f:
|
||||||
|
f.write(f"{title}:\n{json.dumps(data, indent=4)}\n\n")
|
||||||
|
|
||||||
|
|
||||||
async def send_post_request(body: dict):
|
async def send_post_request(body: dict):
|
||||||
@@ -68,7 +73,7 @@ async def call_started(call_session_id):
|
|||||||
body = {
|
body = {
|
||||||
"status": "call_started",
|
"status": "call_started",
|
||||||
"call_session_id": call_session_id,
|
"call_session_id": call_session_id,
|
||||||
"responsibles": [777],
|
"responsibles": [{"id": 777}],
|
||||||
}
|
}
|
||||||
await send_post_request(body)
|
await send_post_request(body)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user