diff --git a/poetry.lock b/poetry.lock index c6c82cdbb..bdb962f86 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. [[package]] name = "absl-py" @@ -487,6 +487,24 @@ humanfriendly = ">=9.1" [package.extras] cron = ["capturer (>=2.4)"] +[[package]] +name = "concurrent-log-handler" +version = "0.9.28" +description = "RotatingFileHandler replacement with concurrency, gzip and Windows support. Size and time based rotation." +optional = false +python-versions = ">=3.6" +groups = ["main"] +files = [ + {file = "concurrent_log_handler-0.9.28-py3-none-any.whl", hash = "sha256:65db25d05506651a61573937880789fc51c7555e7452303042b5a402fd78939c"}, + {file = "concurrent_log_handler-0.9.28.tar.gz", hash = "sha256:4cc27969b3420239bd153779266f40d9713ece814e312b7aa753ce62c6eacdb8"}, +] + +[package.dependencies] +portalocker = ">=1.6.0" + +[package.extras] +dev = ["black", "coverage", "hatch", "pytest", "pytest-cov", "pytest-mock", "pytest-sugar", "ruff"] + [[package]] name = "contourpy" version = "1.3.2" @@ -3388,7 +3406,6 @@ files = [ {file = "portalocker-2.10.1-py3-none-any.whl", hash = "sha256:53a5984ebc86a025552264b459b46a2086e269b21823cb572f8f28ee759e45bf"}, {file = "portalocker-2.10.1.tar.gz", hash = "sha256:ef1bf844e878ab08aee7e40184156e1151f228f103aa5c6bd0724cc330960f8f"}, ] -markers = {main = "extra == \"all\""} [package.dependencies] pywin32 = {version = ">=226", markers = "platform_system == \"Windows\""} @@ -3919,7 +3936,7 @@ files = [ {file = "pywin32-311-cp39-cp39-win_amd64.whl", hash = "sha256:e0c4cfb0621281fe40387df582097fd796e80430597cb9944f0ae70447bacd91"}, {file = "pywin32-311-cp39-cp39-win_arm64.whl", hash = "sha256:62ea666235135fee79bb154e695f3ff67370afefd71bd7fea7512fc70ef31e3d"}, ] -markers = {main = "platform_system == \"Windows\" and extra == \"all\" or sys_platform == \"win32\"", eval = "platform_system == \"Windows\""} +markers = {main = "sys_platform == \"win32\" or platform_system == \"Windows\"", eval = "platform_system == \"Windows\""} [[package]] name = "pyyaml" @@ -6209,4 +6226,4 @@ tree-mem = ["neo4j", "schedule"] [metadata] lock-version = "2.1" python-versions = ">=3.10,<4.0" -content-hash = "1eae4dc9df321c2e5157497c7ce6fb2b1248cb1d4cf7d57e3d38710be977e07b" +content-hash = "04c7b73bd8063f6c8ea8ed6a60b23d59a06de50b8607aff06581cc0e40192e38" diff --git a/pyproject.toml b/pyproject.toml index 265a5ae5d..74dfefc09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ dependencies = [ "fastmcp (>=2.10.5,<3.0.0)", "python-dateutil (>=2.9.0.post0,<3.0.0)", "prometheus-client (>=0.23.1,<0.24.0)", + "concurrent-log-handler (>=0.9.28,<1.0.0)", # Process-safe rotating file handler ] [project.urls] diff --git a/src/memos/log.py b/src/memos/log.py index 874f2c6a7..9325a4861 100644 --- a/src/memos/log.py +++ b/src/memos/log.py @@ -53,6 +53,7 @@ def filter(self, record): record.user_name = get_current_user_name() record.api_path = get_current_api_path() except Exception: + record.api_path = "unknown" record.trace_id = "trace-id" record.env = "prod" record.user_type = "normal" @@ -196,7 +197,7 @@ def close(self): }, "file": { "level": "DEBUG", - "class": "logging.handlers.TimedRotatingFileHandler", + "class": "concurrent_log_handler.ConcurrentTimedRotatingFileHandler", "when": "midnight", "interval": 1, "backupCount": 3,