delete logs dir

This commit is contained in:
cheykrym 2026-03-18 02:41:52 +03:00
parent 54aef338ab
commit 45618ebb61
2 changed files with 8 additions and 7 deletions

View File

@ -138,14 +138,14 @@ def register_error_handlers(app: FastAPI):
async def general_exception_handler(request: Request, exc: Exception): async def general_exception_handler(request: Request, exc: Exception):
# logger.error(f"Unhandled error: {exc}") # logger.error(f"Unhandled error: {exc}")
LOG_DIR = settings.LOG_DIR # LOG_DIR = settings.LOG_DIR
os.makedirs(LOG_DIR, exist_ok=True) # os.makedirs(LOG_DIR, exist_ok=True)
# Уникальный код ошибки (первые 8 символов UUID) # Уникальный код ошибки (первые 8 символов UUID)
error_id = str(uuid.uuid4())[:8] error_id = str(uuid.uuid4())[:8]
date_str = datetime.now().strftime("%Y-%m-%d") # Текущая дата (YYYY-MM-DD) date_str = datetime.now().strftime("%Y-%m-%d") # Текущая дата (YYYY-MM-DD)
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # Полное время ошибки timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # Полное время ошибки
log_filename = os.path.join(LOG_DIR, f"{error_id}_{date_str}.log") # log_filename = os.path.join(LOG_DIR, f"{error_id}_{date_str}.log")
full_log_message = ( full_log_message = (
f"{'-' * 50}\n" f"{'-' * 50}\n"
@ -155,10 +155,11 @@ def register_error_handlers(app: FastAPI):
f"{'-' * 50}\n" f"{'-' * 50}\n"
) )
with open(log_filename, "w", encoding="utf-8") as log_file: print("500 critical error:", full_log_message)
log_file.write(full_log_message) # with open(log_filename, "w", encoding="utf-8") as log_file:
# log_file.write(full_log_message)
print(f"critical error: {LOG_DIR}/{error_id}_{date_str}.log") # print(f"critical error: {LOG_DIR}/{error_id}_{date_str}.log")
return JSONResponse( return JSONResponse(
status_code=500, status_code=500,
content={ content={

View File

@ -1,6 +1,6 @@
[project] [project]
name = "common-lib" name = "common-lib"
version = "0.0.41" version = "0.0.42"
description = "Библиотека общих компонентов для микросервисов yobble" description = "Библиотека общих компонентов для микросервисов yobble"
authors = [{ name = "cheykrym", email = "you@example.com" }] authors = [{ name = "cheykrym", email = "you@example.com" }]
license = "MIT" license = "MIT"