SAP-BTP-Spielwiese/app1/node_modules/@sap/logging/lib/formats/Trace.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

37 lines
910 B
JavaScript

'use strict';
const replaceNewLines = require('./common').replaceNewLines;
// Reference: http://help.sap.com/saphelp_nw74/helpdata/en/48/4f3966e39472d2e10000000a42189c/content.htm
class Trace {
constructor(env) {
this._shouldReplaceNewLines = env.runsOnXSA;
}
format(entryCtx) {
const entry = [
entryCtx.timeCreated.format('MMM DD, YYYY hh:mm:ss A'),
normalizeField(this, entryCtx.component),
normalizeField(this, '[' + entryCtx.id + ']'), // instead of Thread Name
entryCtx.level.toUpperCase() + ':',
normalizeField(this, entryCtx.message)
];
return entry.join(' ');
}
formatNetwork() {
throw new Error('Trace format does not support network logging');
}
}
function normalizeField(formatter, input) {
if (!input) {
return '';
}
return formatter._shouldReplaceNewLines ? replaceNewLines(input) : input;
}
module.exports = Trace;