SAP-BTP-Spielwiese/app1/node_modules/@sap/logging/lib/common.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

27 lines
665 B
JavaScript

'use strict';
const _ = require('lodash');
const assert = require('assert');
const path = require('path');
const consts = require('./constants');
module.exports = {
normalizeComponent,
normalizeLevel
};
function normalizeComponent(component) {
const shortComponent = component.replace(process.env.HOME, '');
const isFilePath = shortComponent !== component;
if (isFilePath && path.sep === '\\') {
return shortComponent.replace(/\\/g, '/');
}
return shortComponent;
}
function normalizeLevel(level) {
level = level.toLowerCase();
assert(_.isNumber(consts.ALL_LEVELS[level]), 'Logging level not among the allowed values');
return level;
}