fix:debug容错,避免阻塞

This commit is contained in:
lvxiaojiao 2024-08-13 16:31:12 +08:00
parent b123d458bc
commit aafbc5aa31

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);