UNPKG

@visulima/pail

Version:

Highly configurable Logger for Node.js, Edge and Browser.

35 lines (31 loc) 1.07 kB
'use strict'; const process = require('node:process'); const writeStream = require('./write-stream-CkNf2Ju8.cjs'); const abstractJsonReporter = require('./abstract-json-reporter-okwLqT9k.cjs'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class JsonReporter extends abstractJsonReporter.AbstractJsonReporter { static { __name(this, "JsonReporter"); } #stdout; #stderr; constructor(options = {}) { super(options); this.#stdout = process.stdout; this.#stderr = process.stderr; } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types setStdout(stdout_) { this.#stdout = stdout_; } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types setStderr(stderr_) { this.#stderr = stderr_; } _log(message, logLevel) { const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout; writeStream.writeStream(message + "\n", stream); } } module.exports = JsonReporter;