Spaces:
Paused
Paused
Update backend/main.py
Browse files- backend/main.py +14 -8
backend/main.py
CHANGED
@@ -6,14 +6,10 @@ from typing import Any, Optional, Tuple, Dict, TypedDict
|
|
6 |
from urllib import parse
|
7 |
from uuid import uuid4
|
8 |
import logging
|
|
|
|
|
9 |
###############################################
|
10 |
# Configure logger
|
11 |
-
###############################################
|
12 |
-
|
13 |
-
class MyUvicornWorker(UvicornWorker):
|
14 |
-
CONFIG_KWARGS = {
|
15 |
-
"log_config": "logging.yaml",
|
16 |
-
}
|
17 |
|
18 |
logging.basicConfig(filename="output.log",
|
19 |
filemode='w',
|
@@ -21,9 +17,18 @@ logging.basicConfig(filename="output.log",
|
|
21 |
datefmt='%H:%M:%S',
|
22 |
level=logging.DEBUG)
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
logger = logging.getLogger("socketio_server_pubsub")
|
25 |
logger.propagate = True
|
26 |
|
|
|
|
|
27 |
import sys
|
28 |
# sys.path.append('/Users/benolojo/DCU/CA4/ca400_FinalYearProject/2024-ca400-olojob2-majdap2/src/backend/')
|
29 |
|
@@ -340,5 +345,6 @@ def send_captions(client_id, original_text, translated_text, call_id):
|
|
340 |
app.mount("/", socketio_app)
|
341 |
|
342 |
if __name__ == '__main__':
|
343 |
-
|
344 |
-
|
|
|
|
6 |
from urllib import parse
|
7 |
from uuid import uuid4
|
8 |
import logging
|
9 |
+
from fastapi.logger import logger as fastapi_logger
|
10 |
+
|
11 |
###############################################
|
12 |
# Configure logger
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
logging.basicConfig(filename="output.log",
|
15 |
filemode='w',
|
|
|
17 |
datefmt='%H:%M:%S',
|
18 |
level=logging.DEBUG)
|
19 |
|
20 |
+
gunicorn_error_logger = logging.getLogger("gunicorn.error")
|
21 |
+
gunicorn_logger = logging.getLogger("gunicorn")
|
22 |
+
uvicorn_access_logger = logging.getLogger("uvicorn.access")
|
23 |
+
uvicorn_access_logger.handlers = gunicorn_error_logger.handlers
|
24 |
+
|
25 |
+
fastapi_logger.handlers = gunicorn_error_logger.handlers
|
26 |
+
|
27 |
logger = logging.getLogger("socketio_server_pubsub")
|
28 |
logger.propagate = True
|
29 |
|
30 |
+
###############################################
|
31 |
+
|
32 |
import sys
|
33 |
# sys.path.append('/Users/benolojo/DCU/CA4/ca400_FinalYearProject/2024-ca400-olojob2-majdap2/src/backend/')
|
34 |
|
|
|
345 |
app.mount("/", socketio_app)
|
346 |
|
347 |
if __name__ == '__main__':
|
348 |
+
fastapi_logger.setLevel(gunicorn_logger.level)
|
349 |
+
else:
|
350 |
+
fastapi_logger.setLevel(logging.DEBUG)
|