Skip to content

Commit

Permalink
feat: supports console log output at the debug level (#29)
Browse files Browse the repository at this point in the history
* feat: supports console log output at the debug level

* Update console.ts

this.console[item] 做兼容

* fix: resolve the issue of run build

* fix: wrap `()=>{}` with ()
  • Loading branch information
notfound945 committed Dec 26, 2023
1 parent 24506f5 commit b669170
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/plugins/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ 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];
this.console[item] =
window.console[item] || window.console.log || (() => {});
window.console[item] = (...args: any[]) => {
this.printLog({
logType: item,
Expand Down
3 changes: 2 additions & 1 deletion types/lib/console.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit b669170

Please sign in to comment.