SAP-BTP-Spielwiese/app1/node_modules/@sap/logging/lib/common.js

28 lines
665 B
JavaScript
Raw Normal View History

'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;
}