Skip to content

Commit

Permalink
fix: logging to debug console
Browse files Browse the repository at this point in the history
  • Loading branch information
mohd-akram committed Jun 10, 2024
1 parent 7f5f014 commit 4744507
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/winston/transports/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'use strict';

const os = require('os');
const inspector = require('inspector');
const { LEVEL, MESSAGE } = require('triple-beam');
const TransportStream = require('winston-transport');

Expand Down Expand Up @@ -49,6 +50,8 @@ module.exports = class Console extends TransportStream {
if (console._stderr) {
// Node.js maps `process.stderr` to `console._stderr`.
console._stderr.write(`${info[MESSAGE]}${this.eol}`);
if (inspector.console.hasOwnProperty(info[LEVEL]))
inspector.console[info[LEVEL]](info[MESSAGE]);
} else {
// console.error adds a newline
console.error(info[MESSAGE]);
Expand Down Expand Up @@ -77,6 +80,8 @@ module.exports = class Console extends TransportStream {
if (console._stdout) {
// Node.js maps `process.stdout` to `console._stdout`.
console._stdout.write(`${info[MESSAGE]}${this.eol}`);
if (inspector.console.hasOwnProperty(info[LEVEL]))
inspector.console[info[LEVEL]](info[MESSAGE]);
} else {
// console.log adds a newline.
console.log(info[MESSAGE]);
Expand Down

0 comments on commit 4744507

Please sign in to comment.