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

40 lines
1.1 KiB
JavaScript

'use strict';
const _ = require('lodash');
const assert = require('assert');
const Base = require('./Base');
const consts = require('../constants');
const normalizeComponent = require('../common').normalizeComponent;
class LoggerBse extends Base {
constructor(logContext, category) {
super(logContext, resolveCategory(category), consts.LOG_LEVELS, consts.DEFAULT_LEVELS.LOGGER);
}
getLevel() {
const level = super.getLevel();
const iLevel = consts.ALL_LEVELS[level];
if (iLevel >= consts.LOG_LEVELS.info) {
return level;
}
return consts.MOST_VERBOSE_LEVEL.LOGGER;
}
}
Object.keys(consts.LOG_LEVELS).forEach(function (level) {
LoggerBse.prototype[level] = function () {
if (this.isEnabled(level)) {
this._outputEntry(level, arguments);
}
};
});
function resolveCategory(category) {
assert(_.isString(category), 'Category argument should be a string');
assert(/^\//.test(category), 'Category should start with a forward slash');
assert(!/\\/.test(category), 'Category should not contain back slashes');
return normalizeComponent(category);
}
module.exports = LoggerBse;