28 lines
665 B
JavaScript
28 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;
|
||
|
}
|