Skip to content

Commit 4e1a991

Browse files
CarltonXiangCaralHsiyuan.wangharvey_xiang
authored
feat: log support time rotating (#504)
* Update API Reference link in README.md * hotfix bug in pref init * feat: log support time rotating * feat: log support time rotating * feat: log support time rotating * feat: delete useless log * feat: delete useless log --------- Co-authored-by: CaralHsi <[email protected]> Co-authored-by: yuan.wang <[email protected]> Co-authored-by: harvey_xiang <[email protected]>
1 parent e234da9 commit 4e1a991

File tree

5 files changed

+11
-48
lines changed

5 files changed

+11
-48
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Designed for **AI companions, role-playing NPCs, and multi-agent systems**, MemO
5353
</div>
5454

5555

56-
Get Free API: [Try API](https://memos-dashboard.openmem.net/quickstart/?source=github)
57-
56+
Get Free API: [Try API](https://memos-dashboard.openmem.net/quickstart/?source=github)
57+
5858

5959
---
6060

@@ -64,7 +64,7 @@ Get Free API: [Try API](https://memos-dashboard.openmem.net/quickstart/?source=g
6464

6565
- **Website**: https://memos.openmem.net/
6666
- **Documentation**: https://memos-docs.openmem.net/home/overview/
67-
- **API Reference**: https://memos-docs.openmem.net/docs/api/info/
67+
- **API Reference**: https://memos-docs.openmem.net/api-reference/configure-memos/
6868
- **Source Code**: https://github.com/MemTensor/MemOS
6969

7070
## 📰 News

src/memos/log.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def _setup_logfile() -> Path:
3737
logfile = Path(settings.MEMOS_DIR / "logs" / "memos.log")
3838
logfile.parent.mkdir(parents=True, exist_ok=True)
3939
logfile.touch(exist_ok=True)
40+
4041
return logfile
4142

4243

@@ -195,10 +196,11 @@ def close(self):
195196
},
196197
"file": {
197198
"level": "DEBUG",
198-
"class": "logging.handlers.RotatingFileHandler",
199+
"class": "logging.handlers.TimedRotatingFileHandler",
200+
"when": "midnight",
201+
"interval": 1,
202+
"backupCount": 3,
199203
"filename": _setup_logfile(),
200-
"maxBytes": 1024**2 * 10,
201-
"backupCount": 10,
202204
"formatter": "standard",
203205
"filters": ["context_filter"],
204206
},

src/memos/mem_scheduler/monitors/dispatcher_monitor.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def _check_pools_health(self) -> None:
135135
pool_info=pool_info,
136136
stuck_max_interval=4,
137137
)
138-
logger.info(f"Pool '{name}'. is_healthy: {is_healthy}. pool_info: {pool_info}")
138+
if not is_healthy:
139+
logger.info(f"Pool '{name}'. is_healthy: {is_healthy}. pool_info: {pool_info}")
140+
139141
with self._pool_lock:
140142
if is_healthy:
141143
pool_info["failure_count"] = 0
@@ -237,20 +239,7 @@ def _check_pool_health(
237239

238240
# Log health status with comprehensive information
239241
if self.dispatcher:
240-
# Check thread activity
241-
active_threads = sum(
242-
1
243-
for t in threading.enumerate()
244-
if t.name.startswith(executor._thread_name_prefix) # pylint: disable=protected-access
245-
)
246-
247-
task_count = self.dispatcher.get_running_task_count()
248242
max_workers = pool_info.get("max_workers", 0)
249-
stuck_count = len(stuck_tasks)
250-
logger.info(
251-
f"Pool health check passed - {active_threads} active threads, "
252-
f"{task_count} running tasks, pool size: {max_workers}, stuck tasks: {stuck_count}"
253-
)
254243

255244
return True, ""
256245

src/memos/mem_scheduler/utils/metrics.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,7 @@ def on_enqueue(
188188
inst_rate = (1.0 / max(1e-3, dt)) if dt is not None else 0.0 # first sample: no spike
189189
ls.last_enqueue_ts = now
190190
ls.backlog += 1
191-
old_lam = ls.lambda_ewma.value_at(now)
192191
ls.lambda_ewma.update(inst_rate, now)
193-
new_lam = ls.lambda_ewma.value_at(now)
194-
logger.info(
195-
f"[DEBUG enqueue] {label} backlog={ls.backlog} dt={dt if dt is not None else '—'}s inst={inst_rate:.3f} λ {old_lam:.3f}{new_lam:.3f}"
196-
)
197192
self._label_topk[label].add(mem_cube_id)
198193
ds = self._get_detail(label, mem_cube_id)
199194
if ds:
@@ -226,12 +221,7 @@ def on_done(
226221
ls.last_done_ts = now
227222
if ls.backlog > 0:
228223
ls.backlog -= 1
229-
old_mu = ls.mu_ewma.value_at(now)
230224
ls.mu_ewma.update(inst_rate, now)
231-
new_mu = ls.mu_ewma.value_at(now)
232-
logger.info(
233-
f"[DEBUG done] {label} backlog={ls.backlog} dt={dt if dt is not None else '—'}s inst={inst_rate:.3f} μ {old_mu:.3f}{new_mu:.3f}"
234-
)
235225
ds = self._detail_stats.get((label, mem_cube_id))
236226
if ds:
237227
prev_ts_d = ds.last_done_ts

src/memos/memories/textual/tree_text_memory/retrieve/recall.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,6 @@ def retrieve(
104104
# Merge and deduplicate by ID
105105
combined = {item.id: item for item in graph_results + vector_results + bm25_results}
106106

107-
graph_ids = {item.id for item in graph_results}
108-
combined_ids = set(combined.keys())
109-
lost_ids = graph_ids - combined_ids
110-
111-
if lost_ids:
112-
print(
113-
f"[DEBUG] The following nodes were in graph_results but missing in combined: {lost_ids}"
114-
)
115-
116107
return list(combined.values())
117108

118109
def retrieve_from_cube(
@@ -150,15 +141,6 @@ def retrieve_from_cube(
150141
# Merge and deduplicate by ID
151142
combined = {item.id: item for item in graph_results}
152143

153-
graph_ids = {item.id for item in graph_results}
154-
combined_ids = set(combined.keys())
155-
lost_ids = graph_ids - combined_ids
156-
157-
if lost_ids:
158-
print(
159-
f"[DEBUG] The following nodes were in graph_results but missing in combined: {lost_ids}"
160-
)
161-
162144
return list(combined.values())
163145

164146
def _graph_recall(

0 commit comments

Comments
 (0)