From d793cf9449d8c9eb5c0815bb14a0012b22b79658 Mon Sep 17 00:00:00 2001 From: vladimir Date: Sun, 2 Aug 2026 02:21:24 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BF=D0=BE=D0=B4=D1=80=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BE=D1=81=D1=82=D0=BE=D1=8F=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/traffic_checker/main.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/traffic_checker/main.py b/src/traffic_checker/main.py index 4d62a55..2ed8745 100644 --- a/src/traffic_checker/main.py +++ b/src/traffic_checker/main.py @@ -239,6 +239,24 @@ def send_telegram_message( response.raise_for_status() +def to_log( + server_target: str, + event_type: str, + traffic_stats: dict, + monthly_period: dict, +): + period_start_str = monthly_period["start"].strftime("%Y-%m-%d %H:%M:%S") + period_reset_str = monthly_period["reset"].strftime("%Y-%m-%d %H:%M:%S") + + print(f"Traffic check for server: {server_target}") + print(f"Event: {event_type}") + print( + f"Traffic stats: {traffic_stats["percentage"]}%, " + f"{traffic_stats["used"]} GB / {traffic_stats["limit"]} GB" + ) + print(f"Monthly period: {period_start_str} -> {period_reset_str}") + + def main(): config = load_config() @@ -273,7 +291,9 @@ def main(): ) send_telegram_message(message) - print(f"""Server {server["target"]}: {event["event"]}""") + to_log( + server["target"], event["event"], traffic_stats, monthly_period + ) except Exception as e: print(f"""Error processing server {server["target"]}: {e}""")