-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
align message level #623
align message level #623
Conversation
Not opposed. Could you add a test for this? |
I added tests, but I'm doing something wrong with the testing library... what happens? is my first time with vows. btw need documentation as well |
The problem is that vows runs the test cases asynchronously which is causing race conditions with the stdMocks module. You can use |
@Kikobeats I fixed your tests and opened a PR over at your fork. If you merge it this PR will pass the CI build :) Hope your feature gets in, it'll be really useful! |
Fix Console Transport's align option tests
thanks @paulhroth! |
No problem! Out of interest, I dig some digging into the codebase regarding this feature. Here's what I found: There's a However Your PR has the advantage of nicely aligning labels, and it's also Transport specific which seems better than being Logger specific to me. The downside is that for custom levels of varying lengths, adding a simple '\t' will not properly align the logs. Fixing this is challenging to do in a non-hacky way because of Winston's current architecture (see this rejected PR #431). It could be argued that the correct solution is to either use Screenshots: Your PR formats labels nicely, but doesn't handle level names of varying length: The Logger's When both are on, alignment is broken by the tab character before the already space-prepended tl;dr: This is very similar to padLevels, but has the advantages of formatting labels better and being Transport specific, and the disadvantage of not properly handling level names of varying length. IMO It could still be useful to add, as long as users are made aware that it is incompatible with the Logger's Suggestion: Maybe I hope this information can help you and @indexzero in going forward with this PR! |
@Kikobeats I'd also recommend aligning only when |
time to merge? |
Will look at getting this merged into |
👍 |
This has been cherry-picked and will be released in |
Ideally would be aligned calculating the level with more characters as reference and adding the spaces necessary for each level to be align.