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