UNPKG

plogger-sdk

Version:

Typescript based frontend logging library compatible with multiple transports and JS/TS frameworks

55 lines 2.15 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { BaseLogger } from "../Logger"; import { logLevel } from "../logLevel"; var ConsoleLogger = /** @class */ (function (_super) { __extends(ConsoleLogger, _super); function ConsoleLogger() { var _this = _super.call(this) || this; //base formatter _this.formatter = "[{{levelName}}] {{timestampLocalIso}} {{filePathWithLine}} {{scope}} : {{rawMessage}}"; return _this; } ConsoleLogger.prototype.log = function (logRecord) { var formattedLog = this.formatLog(logRecord); switch (logRecord.level) { case logLevel.Debug: console.debug(formattedLog); break; case logLevel.Critical: console.error(formattedLog); break; case logLevel.Error: console.error(formattedLog); break; case logLevel.Info: console.info(formattedLog); break; case logLevel.Warn: console.warn(formattedLog); break; case logLevel.Trace: console.trace(formattedLog); break; default: console.log(formattedLog); break; } }; return ConsoleLogger; }(BaseLogger)); export { ConsoleLogger }; //# sourceMappingURL=console-logger.js.map