38 lines
910 B
JavaScript
38 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;
|