Skip to content

Commit

Permalink
fix: 1.暂时禁用window.onerror部分逻辑,这导致一直notice弹出ResizeObserver loop limit …
Browse files Browse the repository at this point in the history
…exceeded提示
  • Loading branch information
JuckZ committed Jul 3, 2023
1 parent 0dd9059 commit 1910318
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { inspect } from 'util';
import chalk from 'chalk';
import { Notice } from 'obsidian';
import { ConstantReference } from '../model/ref';
import type { ReadOnlyReference } from '../model/ref';
import { Notice } from 'obsidian';

class Logger {
private debugEnable: ReadOnlyReference<boolean> = new ConstantReference(false);
Expand All @@ -26,28 +26,28 @@ class Logger {
init(debugEnableVal: ReadOnlyReference<boolean>) {
this.debugEnable = debugEnableVal;
chalk.level = 3;
window.onerror = (msg, url, lineNo, columnNo, error) => {
if (!this.debugEnable.value) {
return;
}
const string = msg.toString().toLowerCase();
const substring = 'script error';
if (string.indexOf(substring) > -1) {
new Notice('Script Error: See Browser Console for Detail');
} else {
const message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error),
].join(' - ');
// window.onerror = (msg, url, lineNo, columnNo, error) => {
// if (!this.debugEnable.value) {
// return;
// }
// const string = msg.toString().toLowerCase();
// const substring = 'script error';
// if (string.indexOf(substring) > -1) {
// new Notice('Script Error: See Browser Console for Detail');
// } else {
// const message = [
// 'Message: ' + msg,
// 'URL: ' + url,
// 'Line: ' + lineNo,
// 'Column: ' + columnNo,
// 'Error object: ' + JSON.stringify(error),
// ].join(' - ');

new Notice(message);
}
// new Notice(message);
// }

return false;
};
// return false;
// };
}
log(...args: any) {
this.printer('log', args, chalk.bgCyanBright.blackBright.bold);
Expand Down

0 comments on commit 1910318

Please sign in to comment.