mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🪚 refactor: Optimize CONSOLE_JSON Debug Logs with Truncation (#4709)
This commit is contained in:
parent
95201908e9
commit
493e64e6db
2 changed files with 24 additions and 3 deletions
|
|
@ -186,8 +186,29 @@ const debugTraverse = winston.format.printf(({ level, message, timestamp, ...met
|
|||
}
|
||||
});
|
||||
|
||||
const jsonTruncateFormat = winston.format((info) => {
|
||||
const truncateObject = (obj) => {
|
||||
const newObj = {};
|
||||
Object.entries(obj).forEach(([key, value]) => {
|
||||
if (typeof value === 'string') {
|
||||
newObj[key] = truncateLongStrings(value, 255);
|
||||
} else if (Array.isArray(value)) {
|
||||
newObj[key] = value.map(condenseArray);
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
newObj[key] = truncateObject(value);
|
||||
} else {
|
||||
newObj[key] = value;
|
||||
}
|
||||
});
|
||||
return newObj;
|
||||
};
|
||||
|
||||
return truncateObject(info);
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
redactFormat,
|
||||
redactMessage,
|
||||
debugTraverse,
|
||||
jsonTruncateFormat,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue