-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: log supports multiple colors #108
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
base: main
Are you sure you want to change the base?
Conversation
}; | ||
const color = colors[type as keyof typeof colors]; | ||
if (color) { | ||
console.log(`${color}%s\x1b[0m`, `[tinyglobby ${new Date().toLocaleTimeString('es')}]${msg}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcoding it to spanish?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that one isn't changed on this pr and comes from main, it's for hardcoding time to be in the hh:mm:ss format, couldn't find a "international" locale that did this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense. Could be worth a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swedish is quite often used for this kinda thing but that's a bit risky though, I've opened an issue in NodeJS a while ago for date string not respecting 2 digits with 0 padding in Node 22. Then a Node maintainer replied with this comment
Data changes constantly. Look at https://www.unicode.org/cldr/charts/44/delta/index.html and pick any locale.
toLocaleString()
is completely inappropriate as an API to expect a constant format. It should display what's correct for Swedish, which might change over time.
It's usually safer to use new Date(date).toISOString()
even though it's UTC TZ
i think this pr is probably a bit overkill, it would need more handling for systems that don't support colors and it would increase bundle size for something that is just meant to be a tiny debug function to share the output of if stuff breaks. could use |
Add colors to distinguish different types of logs to facilitate quick access to information.