UNPKG

@appruut/logger

Version:

Logging module for Node.js applications

39 lines (38 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FakeLogger = void 0; const Logger_1 = require("./Logger"); class FakeLogger extends Logger_1.Logger { constructor(config, pino) { if (!pino) { const cloned = Object.assign({}, config, { prettyPrint: false, stream: { logs: [], write: function writer(line) { const log = JSON.parse(line); delete log.timestamp; this.logs.push(log); }, }, }); super(cloned); } else { super(config, pino); } } get logs() { return this.config.stream.logs; } child(bindings) { if (!this.config.enabled) { return this; } return new FakeLogger(this.config, this.pino.child(bindings)); } clear() { this.config.stream.logs = []; } } exports.FakeLogger = FakeLogger;