Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight warn and error logs with chalk #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thomasdax98
Copy link
Member

@thomasdax98 thomasdax98 commented Feb 28, 2025

console.warn is now highlighted in yellow and console.error is highlighted in red.

In my opinion, this increases readability and clarity and makes it less likely to overlook relevant information.


Before:

Bildschirmfoto 2025-02-28 um 13 40 42

Now:

Bildschirmfoto 2025-02-28 um 13 39 55

const originalWarn = console.warn;

console.error = (...args) => {
const formattedArgs = args.map((arg) => (typeof arg === "object" ? util.inspect(arg, { depth: null, colors: true }) : chalk.red(arg)));
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise error objects aren't displayed correctly

Before:
Bildschirmfoto 2025-02-28 um 13 35 42

Now:
Bildschirmfoto 2025-02-28 um 13 35 58

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we highlight objects as well?

@@ -28,6 +28,7 @@
"start": "npm run clean && tsc --watch"
},
"dependencies": {
"chalk": "^4.1.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to use chalk v4 instead of v5 because v5 is ESM only

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