From 256b295739296f33344d3874ce190d06fa217e41 Mon Sep 17 00:00:00 2001 From: Silence_Lurker Date: Fri, 16 Jan 2026 15:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E6=8E=A7=E5=88=B6=E5=8F=B0=E4=BB=A5=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=8A=AB=E6=8C=81=EF=BC=8C=E5=B9=B6=E5=9C=A8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=97=B6=E8=BE=93=E5=87=BA=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SL/bus/Amily2Bus.js | 21 ++++++++++++++++++++- SL/bus/log/Logger.js | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/SL/bus/Amily2Bus.js b/SL/bus/Amily2Bus.js index 8a9f4c6..957e026 100644 --- a/SL/bus/Amily2Bus.js +++ b/SL/bus/Amily2Bus.js @@ -1,8 +1,26 @@ import Logger from './log/Logger.js'; import FilePipe from './file/FilePipe.js'; +// 【逃生通道】创建一个纯净的 Console 对象,绕过任何潜在的劫持 +const getSafeConsole = () => { + try { + if (window._amilySafeConsole) return window._amilySafeConsole; + + const iframe = document.createElement('iframe'); + iframe.style.display = 'none'; + document.body.appendChild(iframe); + const safe = iframe.contentWindow.console; + // document.body.removeChild(iframe); // 保持 iframe 以维持 console 引用有效 + window._amilySafeConsole = safe; + return safe; + } catch (e) { + return window.console; // Fallback + } +}; + class Amily2Bus { constructor() { + this.safeConsole = getSafeConsole(); /** @type {Logger|null} */ this.Logger = new Logger(); /** @type {FilePipe|null} */ @@ -11,7 +29,7 @@ class Amily2Bus { // 已注册插件列表,防止重复注册 this.registry = new Set(); - console.log('[Amily2Bus] Core container initialized with secure registry.'); + this.safeConsole.log('[Amily2Bus] Core container initialized with secure registry.'); } /** @@ -23,6 +41,7 @@ class Amily2Bus { * @param {string} [plugin='Global'] 来源插件/命名空间,调试时可指定如 'Console' */ log(type, message, origin = 'Bus', plugin = 'Global') { + this.safeConsole.error('[Amily2Bus DEBUG] log called (via SafeConsole):', { type, loggerExists: !!this.Logger }); if (this.Logger) { this.Logger.process(plugin, origin, type, message); } diff --git a/SL/bus/log/Logger.js b/SL/bus/log/Logger.js index 5b85f2e..0c09656 100644 --- a/SL/bus/log/Logger.js +++ b/SL/bus/log/Logger.js @@ -144,6 +144,9 @@ class Logger { * 统一处理过滤、格式化和输出,支持默认归属 Global */ process(plugin, origin, type, message, inFile = false) { + // [DEBUG] 强制输出以确认方法被调用 (使用 error 级别防止被过滤) + console.error('[Logger DEBUG] Process called:', { plugin, origin, type, message }); + // 1. 默认归属处理 const safePlugin = plugin || 'Global'; const safeOrigin = origin || 'System';