log html fixes
This commit is contained in:
parent
66c11515ca
commit
dd2c7035b5
2 changed files with 17 additions and 16 deletions
|
@ -97,11 +97,11 @@ export default /*html*/ `
|
|||
}
|
||||
|
||||
if(Array.isArray(json)){
|
||||
addSpaces(depth, "[");
|
||||
|
||||
addSpaces(0, "[");
|
||||
let doBreak = JSON.stringify(json).length > 64;
|
||||
json.forEach((e,i) => {
|
||||
if(i == 0) addBreak();
|
||||
addSpaces(depth+2);
|
||||
if(i == 0 && doBreak) addBreak();
|
||||
if(doBreak) addSpaces(depth+2);
|
||||
|
||||
addData(e);
|
||||
|
||||
|
@ -111,32 +111,33 @@ export default /*html*/ `
|
|||
elems.push(k);
|
||||
}
|
||||
|
||||
addBreak();
|
||||
if(doBreak) addBreak();
|
||||
});
|
||||
addSpaces(depth, "]");
|
||||
addSpaces(doBreak ? depth : 0, "]");
|
||||
}else{
|
||||
addSpaces(depth, "{");
|
||||
addSpaces(0, "{");
|
||||
let keys = Object.keys(json);
|
||||
let doBreak = JSON.stringify(json).length > 64;
|
||||
for(let i = 0; i < keys.length; i++){
|
||||
if(i == 0) addBreak();
|
||||
if(i == 0 && doBreak) addBreak();
|
||||
let key = keys[i];
|
||||
|
||||
addSpaces(depth+2);
|
||||
if(doBreak) addSpaces(depth+2);
|
||||
let keyElem = document.createElement("span");
|
||||
keyElem.innerText = key + ": ";
|
||||
elems.push(keyElem);
|
||||
|
||||
addData(json[key]);
|
||||
|
||||
if(i+1 < json.length){
|
||||
if(i+1 < keys.length){
|
||||
let k = document.createElement("span");
|
||||
k.innerText = ", ";
|
||||
elems.push(k);
|
||||
}
|
||||
|
||||
addBreak();
|
||||
if(doBreak) addBreak();
|
||||
}
|
||||
addSpaces(depth, "}");
|
||||
addSpaces(doBreak ? depth : 0, "}");
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ const consorArgs = (args: any[]) => {
|
|||
}
|
||||
const censorLogArg = (arg: any) => {
|
||||
if (typeof arg != "object" || arg == null || arg instanceof Error) return arg;
|
||||
let out: any = {};
|
||||
let out: any = Array.isArray(arg) ? [] : {};
|
||||
for (let key in arg) {
|
||||
if ((["accountKey", "sign", "publicKey", "token"]).includes(key)) out[key] = new Array(Math.min(arg[key].length, 50)).fill("*").join("");
|
||||
else out[key] = censorLogArg(arg[key]);
|
||||
|
|
Loading…
Reference in a new issue