function extractCustomDetails()

in desktop/src/@batch-flask/utils/logging/pretty-stream.ts [101:130]


function extractCustomDetails(rec) {
    const skip = new Set(["name", "hostname", "pid", "level", "component", "msg",
        "time", "v", "src", "err", "client_req", "client_res", "req", "res"]);

    const details: string[] = [];
    const extras = {};

    for (const key of Object.keys(rec)) {
        if (skip.has(key)) { continue; }
        let value = rec[key];
        if (typeof value === "undefined") { value = ""; }
        let stringified = false;
        if (typeof value !== "string") {
            value = JSON.stringify(value, null, 2);
            stringified = true;
        }
        if (value.indexOf("\n") !== -1 || value.length > 50) {
            details.push(key + ": " + value);
        } else if (!stringified && (value.indexOf(" ") !== -1 || value.length === 0)) {
            extras[key] = JSON.stringify(value);
        } else {
            extras[key] = value;
        }
    }

    return {
        details: details,
        extras: extras,
    };
}