Skip to content

Comments

Replace Winston Logger with Pino#506

Open
AbdurrehmanSubhani wants to merge 5 commits intodevfrom
add-error-log-path-to-console
Open

Replace Winston Logger with Pino#506
AbdurrehmanSubhani wants to merge 5 commits intodevfrom
add-error-log-path-to-console

Conversation

@AbdurrehmanSubhani
Copy link
Contributor

@AbdurrehmanSubhani AbdurrehmanSubhani commented Nov 11, 2024

This PR replaces the current logger (Winston) with (Pino).

The main reason for changing the underlying logger is Winston's issues handling transports alongside process.exit() usage, here's a link to the issue:
winstonjs/winston#228

We use process.exit() in a lot of places throughout the sdk hence using Winston for reliable file log dumping was becoming a problem.
Pino supports process.exit with their transport api making it a better choice for maintain log dump file.

** The error in the image was for testing purposes, the chat code works fine as expected

image

@vercel
Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 0:22am
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 0:22am

['uncaughtException', 'unhandledRejection'].forEach(event =>
process.on(event, (err, err2) => {
console.error('cli uncaught exception', err, err2);
console.log("A complete log of this run can be found in: \n", logger.getLogFilePath());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

Copy link
Contributor

@avaer avaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but does that mean we can remove the winston install to reduce package bloat?

@AbdurrehmanSubhani
Copy link
Contributor Author

It looks good, but does that mean we can remove the winston install to reduce package bloat?

Yeah we should, particularly because winston does not work with transport log with process.exit(), better to remove it entirely.

Removing it in the next commit

@AbdurrehmanSubhani AbdurrehmanSubhani changed the title Add error log path to console Replace Winston Logger with Pino Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants