Skip to content

Commit

Permalink
Allow logger to work in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Jan 15, 2025
1 parent e17566a commit 80be2aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/common/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ const JSONReporter = (
options: ConsolaOptions;
},
) => {
const writer = process?.stdout ? process.stdout.write : console.info;
const writerError = process?.stderr ? process.stderr.write : console.error;
if (context.options.level === ConsolaLogLevels.error) {
process.stderr.write(`${JSON.stringify(message)}\n`);
writer(`${JSON.stringify(message)}\n`);
} else {
process.stdout.write(`${JSON.stringify(message)}\n`);
writerError(`${JSON.stringify(message)}\n`);
}
};

Expand Down

0 comments on commit 80be2aa

Please sign in to comment.