delete logs dir
This commit is contained in:
parent
54aef338ab
commit
45618ebb61
@ -138,14 +138,14 @@ def register_error_handlers(app: FastAPI):
|
||||
async def general_exception_handler(request: Request, exc: Exception):
|
||||
# logger.error(f"Unhandled error: {exc}")
|
||||
|
||||
LOG_DIR = settings.LOG_DIR
|
||||
os.makedirs(LOG_DIR, exist_ok=True)
|
||||
# LOG_DIR = settings.LOG_DIR
|
||||
# os.makedirs(LOG_DIR, exist_ok=True)
|
||||
# Уникальный код ошибки (первые 8 символов UUID)
|
||||
error_id = str(uuid.uuid4())[:8]
|
||||
date_str = datetime.now().strftime("%Y-%m-%d") # Текущая дата (YYYY-MM-DD)
|
||||
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 = (
|
||||
f"{'-' * 50}\n"
|
||||
@ -155,10 +155,11 @@ def register_error_handlers(app: FastAPI):
|
||||
f"{'-' * 50}\n"
|
||||
)
|
||||
|
||||
with open(log_filename, "w", encoding="utf-8") as log_file:
|
||||
log_file.write(full_log_message)
|
||||
print("500 critical error:", 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(
|
||||
status_code=500,
|
||||
content={
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "common-lib"
|
||||
version = "0.0.41"
|
||||
version = "0.0.42"
|
||||
description = "Библиотека общих компонентов для микросервисов yobble"
|
||||
authors = [{ name = "cheykrym", email = "you@example.com" }]
|
||||
license = "MIT"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user