From 0e45055fd9d8a8431eeb5136f263800a2bb1702a Mon Sep 17 00:00:00 2001 From: kobaltgit Date: Mon, 6 Apr 2026 13:08:55 +0300 Subject: [PATCH] fix: robust log retrieval with stderr merging and status check - Merged stdout and stderr in cmd_logs to capture all container output. - Added explicit check for container status when no logs are returned. - Improved feedback for empty logs in running containers. - Fixed "No logs" placeholder when container writes exclusively to stderr. --- install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 0f63798..3e4cbf6 100644 --- a/install.sh +++ b/install.sh @@ -332,18 +332,18 @@ async def cmd_restart(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: async def cmd_logs(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: if not update.effective_user or not _ok(update.effective_user.id): return - running = await proxy_running() - if not running: - text = "❌ Контейнер не найден или остановлен." + is_running = await proxy_running() + if not is_running: + text = "❌ Прокси-контейнер не запущен или не найден." else: - # Запрашиваем 50 строк и объединяем выводы + # Запрашиваем 50 строк и объединяем выводы (out и err) code, out, err = await sh("docker", "logs", "--tail", "50", CONTAINER_NAME, timeout=15) - combined_logs = (out.strip() + "\n" + err.strip()).strip() + full_logs = (out.strip() + "\n" + err.strip()).strip() - if not combined_logs: - text = "📋 Контейнер запущен, но логи пока пусты.\nПопробуйте подключиться к прокси, чтобы появились записи." + if not full_logs: + text = "📋 Контейнер запущен, но записей в логах пока нет.\nПопробуйте подключиться к прокси, чтобы данные появились." else: - text = f"
{html.escape(combined_logs)}
" + text = f"
{html.escape(full_logs)}
" kb = InlineKeyboardMarkup([[InlineKeyboardButton("◀️ Меню", callback_data="menu_main")]]) if update.callback_query: