From 337f31ddab557ccd24492eee4ada9e92a180ae39 Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Wed, 1 Jul 2026 16:07:22 -0700 Subject: [PATCH] =?UTF-8?q?fix(prax):=20per-bot=20telegram=20log=20attribu?= =?UTF-8?q?tion=20via=20AIPASS=5FBOT=5FID/AIPASS=5FLOG=5FNAME=20in=20get?= =?UTF-8?q?=5Fcaller=5Finfo=20=E2=80=94=20bots=20no=20longer=20collapse=20?= =?UTF-8?q?into=20shared=20skills=5Fbase=5Fbot.log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/handlers/logging/introspection.py | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/aipass/prax/apps/handlers/logging/introspection.py b/src/aipass/prax/apps/handlers/logging/introspection.py index 2765f611..6abf8116 100755 --- a/src/aipass/prax/apps/handlers/logging/introspection.py +++ b/src/aipass/prax/apps/handlers/logging/introspection.py @@ -14,13 +14,13 @@ Used by logger_setup.py to route logs to correct files. """ import logging - -logger = logging.getLogger(__name__) from pathlib import Path from typing import Optional from aipass.prax.apps.handlers.json import json_handler +logger = logging.getLogger(__name__) + _PRAX_INTERNAL_MARKERS = ( "/prax/apps/modules/logger.py", "/prax/apps/handlers/", @@ -85,14 +85,29 @@ def get_caller_info() -> tuple: get_calling_module_path() are called separately from different stack depths, potentially finding different external callers. + Env var overrides (checked in order): + AIPASS_LOG_NAME — explicit module name override for any process + AIPASS_BOT_ID — set by telegram-bot@.service, mapped to bot_{id} + Returns: (module_name, module_path, branch_name) — branch_name may be None """ + import os + caller_path = _find_external_caller_path() + branch = detect_branch_from_path(caller_path) if caller_path else None + + log_name = os.environ.get("AIPASS_LOG_NAME") + if log_name: + return (log_name, caller_path, branch) + + bot_id = os.environ.get("AIPASS_BOT_ID") + if bot_id: + return (f"bot_{bot_id}", caller_path, branch) + if not caller_path: return ("unknown_module", None, None) module_name = Path(caller_path).stem - branch = detect_branch_from_path(caller_path) return (module_name, caller_path, branch)