function buildSource()

in functions/source/LoggingProcessorLambda/index.js [16:41]


function buildSource(message, extractedFields) {
    if (extractedFields) {
        const source = {};
        for (const key in extractedFields) {
            if (Object.prototype.hasOwnProperty.call(extractedFields, key) &&
                extractedFields[key]) {
                const value = extractedFields[key];
                if (isNumeric(value)) {
                    source[key] = 1 * value;
                    continue;
                }
                const jsonSubString = extractJson(value);
                if (jsonSubString !== null) {
                    source["$" + key] = JSON.parse(jsonSubString);
                }
                source[key] = value;
            }
        }
        return source;
    }
    const jsonSubString = extractJson(message);
    if (jsonSubString !== null) {
        return JSON.parse(jsonSubString);
    }
    return {};
}