alessandro trinca tornidor
commited on
Commit
·
6a4a012
1
Parent(s):
727d8fa
doc: improve app log messages
Browse files- my_ghost_writer/app.py +11 -3
my_ghost_writer/app.py
CHANGED
|
@@ -64,7 +64,7 @@ def get_words_frequency(body: RequestTextFrequencyBody | str) -> JSONResponse:
|
|
| 64 |
try:
|
| 65 |
app.mount("/static", StaticFiles(directory=STATIC_FOLDER, html=True), name="static")
|
| 66 |
except Exception as ex_mount_static:
|
| 67 |
-
app_logger.error(f"Failed to mount static folder: {STATIC_FOLDER}, exception: {ex_mount_static}!")
|
| 68 |
if not API_MODE:
|
| 69 |
app_logger.exception(f"since API_MODE is {API_MODE} we will raise the exception!")
|
| 70 |
raise ex_mount_static
|
|
@@ -79,7 +79,7 @@ try:
|
|
| 79 |
def index() -> FileResponse:
|
| 80 |
return FileResponse(path=STATIC_FOLDER / "index.html", media_type="text/html")
|
| 81 |
except Exception as ex_route_main:
|
| 82 |
-
app_logger.error(f"Failed to prepare the main route, exception: {ex_route_main}!")
|
| 83 |
if not API_MODE:
|
| 84 |
app_logger.exception(f"since API_MODE is {API_MODE} we will raise the exception!")
|
| 85 |
raise ex_route_main
|
|
@@ -87,9 +87,17 @@ except Exception as ex_route_main:
|
|
| 87 |
|
| 88 |
if __name__ == "__main__":
|
| 89 |
try:
|
| 90 |
-
app_logger.info(f"Starting fastapi/gradio application {fastapi_title}, run in api mode: {API_MODE}...")
|
| 91 |
uvicorn.run("my_ghost_writer.app:app", host=DOMAIN, port=PORT, reload=bool(IS_TESTING))
|
| 92 |
except Exception as ex_run:
|
| 93 |
print(f"fastapi/gradio application {fastapi_title}, exception:{ex_run}!")
|
| 94 |
app_logger.exception(f"fastapi/gradio application {fastapi_title}, exception:{ex_run}!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
raise ex_run
|
|
|
|
| 64 |
try:
|
| 65 |
app.mount("/static", StaticFiles(directory=STATIC_FOLDER, html=True), name="static")
|
| 66 |
except Exception as ex_mount_static:
|
| 67 |
+
app_logger.error(f"Failed to mount static folder: {STATIC_FOLDER}, exception: {ex_mount_static}, API_MODE: {API_MODE}!")
|
| 68 |
if not API_MODE:
|
| 69 |
app_logger.exception(f"since API_MODE is {API_MODE} we will raise the exception!")
|
| 70 |
raise ex_mount_static
|
|
|
|
| 79 |
def index() -> FileResponse:
|
| 80 |
return FileResponse(path=STATIC_FOLDER / "index.html", media_type="text/html")
|
| 81 |
except Exception as ex_route_main:
|
| 82 |
+
app_logger.error(f"Failed to prepare the main route, exception: {ex_route_main}, API_MODE: {API_MODE}!")
|
| 83 |
if not API_MODE:
|
| 84 |
app_logger.exception(f"since API_MODE is {API_MODE} we will raise the exception!")
|
| 85 |
raise ex_route_main
|
|
|
|
| 87 |
|
| 88 |
if __name__ == "__main__":
|
| 89 |
try:
|
| 90 |
+
app_logger.info(f"Starting fastapi/gradio application {fastapi_title}, run in api mode: {API_MODE} (no static folder and main route)...")
|
| 91 |
uvicorn.run("my_ghost_writer.app:app", host=DOMAIN, port=PORT, reload=bool(IS_TESTING))
|
| 92 |
except Exception as ex_run:
|
| 93 |
print(f"fastapi/gradio application {fastapi_title}, exception:{ex_run}!")
|
| 94 |
app_logger.exception(f"fastapi/gradio application {fastapi_title}, exception:{ex_run}!")
|
| 95 |
+
# important env variables: ALLOWED_ORIGIN_LIST, API_MODE, DOMAIN, IS_TESTING, LOG_LEVEL, PORT, STATIC_FOLDER
|
| 96 |
+
app_logger.error(f"ALLOWED_ORIGIN_LIST: '{ALLOWED_ORIGIN_LIST}'")
|
| 97 |
+
app_logger.error(f"API_MODE: '{API_MODE}'")
|
| 98 |
+
app_logger.error(f"DOMAIN: '{DOMAIN}'")
|
| 99 |
+
app_logger.error(f"IS_TESTING: '{IS_TESTING}'")
|
| 100 |
+
app_logger.error(f"LOG_LEVEL: '{LOG_LEVEL}'")
|
| 101 |
+
app_logger.error(f"PORT: '{PORT}'")
|
| 102 |
+
app_logger.error(f"STATIC_FOLDER: '{STATIC_FOLDER}'")
|
| 103 |
raise ex_run
|