Handle empty docker log periods

This commit is contained in:
2026-02-08 00:54:13 +03:00
parent be65398b86
commit 61236b9d60
2 changed files with 13 additions and 0 deletions

View File

@@ -117,6 +117,11 @@ async def logs_options(cb: CallbackQuery):
if action == "tail":
await cb.answer("Loading logs…")
rc, out = await docker_cmd(["logs", "--tail", "80", real])
if rc != 0:
await cb.message.answer(out)
return
if not out.strip():
out = "(no logs)"
await cb.message.answer(
f"📜 **Logs: {alias}**\n```{out}```",
parse_mode="Markdown"
@@ -132,6 +137,11 @@ async def logs_options(cb: CallbackQuery):
since_ts = str(int(time.time() - seconds))
await cb.answer("Loading logs…")
rc, out = await docker_cmd(["logs", "--since", since_ts, "--tail", "200", real])
if rc != 0:
await cb.message.answer(out)
return
if not out.strip():
out = "(no logs for period)"
await cb.message.answer(
f"📜 **Logs: {alias}**\n```{out}```",
parse_mode="Markdown"

View File

@@ -102,6 +102,9 @@ async def log_filter_input(msg: Message):
if rc != 0:
await msg.answer(out, reply_markup=docker_kb)
return
if not out.strip():
await msg.answer("⚠️ Нет логов за выбранный период", reply_markup=docker_kb)
return
lines = [line for line in out.splitlines() if needle.lower() in line.lower()]
filtered = "\n".join(lines) if lines else "(no matches)"