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