From 5ec82838a9e95df6a7fa2cb910c60b9dd1de566a Mon Sep 17 00:00:00 2001 From: notfound945 <732039303@qq.com> Date: Sun, 24 Dec 2023 21:55:54 +0800 Subject: [PATCH 1/4] feat: supports console log output at the debug level --- src/plugins/console.ts | 8 +++++++- types/lib/console.d.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/console.ts b/src/plugins/console.ts index b27b2934..268563a9 100644 --- a/src/plugins/console.ts +++ b/src/plugins/console.ts @@ -16,7 +16,13 @@ export default class ConsolePlugin implements PageSpyPlugin { if (ConsolePlugin.hasInitd) return; ConsolePlugin.hasInitd = true; - const type: SpyConsole.ProxyType[] = ['log', 'info', 'error', 'warn']; + const type: SpyConsole.ProxyType[] = [ + 'log', + 'info', + 'error', + 'warn', + 'debug', + ]; type.forEach((item) => { this.console[item] = window.console[item]; window.console[item] = (...args: any[]) => { diff --git a/types/lib/console.d.ts b/types/lib/console.d.ts index 386ef8f4..9c97b001 100644 --- a/types/lib/console.d.ts +++ b/types/lib/console.d.ts @@ -1,10 +1,11 @@ -export type ProxyType = 'log' | 'info' | 'error' | 'warn'; +export type ProxyType = 'log' | 'info' | 'error' | 'warn' | 'debug'; export type DataType = | 'log' | 'info' | 'error' | 'warn' + | 'debug' | 'debug-origin' | 'debug-eval'; export interface DataItem { From 31ba2ce66fea5f154a9a357ab580e0e40af168c5 Mon Sep 17 00:00:00 2001 From: Purple Hydrogen Leak <1617291164@qq.com> Date: Mon, 25 Dec 2023 09:42:14 +0800 Subject: [PATCH 2/4] Update console.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this.console[item] 做兼容 --- src/plugins/console.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/console.ts b/src/plugins/console.ts index 268563a9..23cd24d1 100644 --- a/src/plugins/console.ts +++ b/src/plugins/console.ts @@ -23,8 +23,8 @@ export default class ConsolePlugin implements PageSpyPlugin { 'warn', 'debug', ]; - type.forEach((item) => { - this.console[item] = window.console[item]; + type.forEach((item) => + this.console[item] = window.console[item] || window.console.log || () => {}; window.console[item] = (...args: any[]) => { this.printLog({ logType: item, From e98c588c5b31b32520bbd2c6b44df5b00a1eb24d Mon Sep 17 00:00:00 2001 From: notfound945 <732039303@qq.com> Date: Mon, 25 Dec 2023 13:00:57 +0800 Subject: [PATCH 3/4] fix: resolve the issue of run build --- src/plugins/console.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/console.ts b/src/plugins/console.ts index 23cd24d1..9e186958 100644 --- a/src/plugins/console.ts +++ b/src/plugins/console.ts @@ -23,8 +23,8 @@ export default class ConsolePlugin implements PageSpyPlugin { 'warn', 'debug', ]; - type.forEach((item) => - this.console[item] = window.console[item] || window.console.log || () => {}; + type.forEach((item) => { + this.console[item] = window.console[item] || window.console.log; window.console[item] = (...args: any[]) => { this.printLog({ logType: item, From 0e84a0b4a23711283794c3172c3193cae329dc28 Mon Sep 17 00:00:00 2001 From: notfound945 <732039303@qq.com> Date: Mon, 25 Dec 2023 14:19:05 +0800 Subject: [PATCH 4/4] fix: wrap `()=>{}` with () --- src/plugins/console.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/console.ts b/src/plugins/console.ts index 9e186958..481f2feb 100644 --- a/src/plugins/console.ts +++ b/src/plugins/console.ts @@ -24,7 +24,8 @@ export default class ConsolePlugin implements PageSpyPlugin { 'debug', ]; type.forEach((item) => { - this.console[item] = window.console[item] || window.console.log; + this.console[item] = + window.console[item] || window.console.log || (() => {}); window.console[item] = (...args: any[]) => { this.printLog({ logType: item,