UNPKG

@triviality/logger

Version:

Typescript loggers with an interface that support composition

55 lines 2.15 kB
"use strict"; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; Object.defineProperty(exports, "__esModule", { value: true }); var LoggerInterface_1 = require("./LoggerInterface"); var AbstractFunctionLogger = /** @class */ (function () { function AbstractFunctionLogger() { } AbstractFunctionLogger.prototype.log = function (level, message) { var optionalParams = []; for (var _i = 2; _i < arguments.length; _i++) { optionalParams[_i - 2] = arguments[_i]; } switch (level) { case LoggerInterface_1.LogLevel.trace: this.trace.apply(this, __spread([message], optionalParams)); break; case LoggerInterface_1.LogLevel.debug: this.debug.apply(this, __spread([message], optionalParams)); break; case LoggerInterface_1.LogLevel.info: this.info.apply(this, __spread([message], optionalParams)); break; case LoggerInterface_1.LogLevel.warn: this.warn.apply(this, __spread([message], optionalParams)); break; case LoggerInterface_1.LogLevel.error: this.error.apply(this, __spread([message], optionalParams)); break; default: throw new Error("Log level \"" + level + "\" not supported"); } }; return AbstractFunctionLogger; }()); exports.AbstractFunctionLogger = AbstractFunctionLogger; //# sourceMappingURL=AbstractFunctionLogger.js.map