Merge pull request #10767 from hsm-lv/fix-util-debug

fix:debug容错,避免阻塞
This commit is contained in:
hsm-lv 2024-08-13 16:33:36 +08:00 committed by GitHub
commit 1cdd81909c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -474,11 +474,18 @@ export function debug(cat: Category, msg: string, ext?: object) {
console.debug(ext);
console.groupEnd();
let extStr = '';
try {
extStr = JSON.stringify(ext);
} catch (e) {
console.error(e);
}
const log = {
cat,
level: 'debug',
msg: msg,
ext: JSON.stringify(ext)
ext: extStr
};
store.logs.push(log);
}
@ -492,11 +499,19 @@ export function warning(cat: Category, msg: string, ext?: object) {
if (!isEnabled) {
return;
}
let extStr = '';
try {
extStr = JSON.stringify(ext);
} catch (e) {
console.error(e);
}
const log = {
cat,
level: 'warn',
msg: msg,
ext: JSON.stringify(ext)
ext: extStr
};
console.groupCollapsed('amis debug', msg);