-
-
Notifications
You must be signed in to change notification settings - Fork 232
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 output when using multiple scopes #49
Comments
This is sort of a separate issue, although it’s related. Even if the scopes are the same length, the longest label is calculated per-instance, causing the last column to not align. What are your thoughts? Is this something you want to see fixed/handled? Or are you not interested? I came up with a third way of handling this that might work. It might not necessitate changing the interface at all. Because Node modules are cached, static properties are effectively shared. So I think when a new instance is created, we could append the options to some static property, then rather than looking in the current instance to determine longest line length for scope, label, etc, we'd look in the static property. Does that make sense? Thoughts? |
In general, it is easier to visually distinguish messages originating from the same scope/logger, due to their unique alignment, when mixed with a large number of messages originating from different scopes/loggers. A nice example is the log output that semantic-release emits. But this could definitely be useful, we could add a couple of options, to align all messages across all instances or scopes, without them, of course, having to be mutually exclusive : ) |
@klauscfhq I just opened a PR for the first issue. Let me know what you think! |
Is your feature request related to a problem? Please describe.
Much of the logger output is aligned to columns. You can see it in screenshots in the README.
However scopes are not, which looks weird and seems inconsistent.
Describe the solution you'd like
Right now each instance only knows about one scope, so it wouldn't know what the maximum possible scope length is in order to add the right amount of padding. But there are a few ways around this. We could pass in all the scopes to each instance. It’s a little gross. Or one instance could be responsible for multiple scopes. That would require altering the interface a bit. Something like:
If you're using multiple scopes you might have already created a similar interface yourself to simplify usage. For example, I don’t re-instantiate new instances with the scope I need in different parts of my application. I have one module that contains all the instances, each with their own scope, and then I access the one I need, much like in the example above.
The text was updated successfully, but these errors were encountered: