-
Notifications
You must be signed in to change notification settings - Fork 308
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
Add color to warnings #818
Comments
I'm keen to work on this, but would appreciate ideas/suggestions before proceeding. |
Why wouldn't we use something like |
Funny you should ask; yesterday I was listening to a podcast interview with the maintainer, and was thinking "could Twine unify all of its output (including progress bars) with Rich?" I've been looking for an excuse to play with that library, and would be happy to do that for Twine. @sigmavirus24 Do you have suggestions on a roadmap for migrating to Rich? |
Can you share more about what you're thinking about here? It sounds like you want a kind of phased transition to it and I'm curious if that's right and what is leading you to that desire |
I think my overall desire is to unify Twine's output under a single, consistent API. Off the top of my head, and having not thoroughly investigated Rich's features, that could include:
|
Ah, I thought you were asking about introducing rich behind some sort of feature-flag to gather feedback from folks as opposed to making a hard switch.
So, I'll repeat that the easiest way to implement As for Finally, Rich has it's own built-in logging handler: https://rich.readthedocs.io/en/stable/logging.html which is what made me think of this in the first place.
👍 to all of these. |
I think we're already doing this: Lines 149 to 155 in 4c9d8c1
Okay. I'll aim to normalize to |
In my proposed roadmap in #818 (comment), I've added an entry for migrating Lines 105 to 109 in 658037f
This reminds me of the discussion about refactoring commands in #659, but I'm not inclined to go down that rabbit hole right now. |
@sigmavirus24 @di My next step is to migrate Lines 105 to 109 in c5769e0
It seems that's only used for testing, e.g.: Lines 99 to 101 in 12469ce
My preference would be to remove Alternatively, I'm guessing it's possible to configure |
Yes, let's do that. Also, I'll reiterate, |
I've updated the checklist in #818 (comment), choosing to omit tracebacks because they seem too rich. So, I think this is done, and further enhancements can be suggested in new issues. |
While working on #815 and #817, I remembered a suggestion for this. I think it would make them more obvious.
pip does this, with a custom
logging.StreamHandler
.There are also a couple packages that hook into
logging
and usecolorama
(which Twine already uses for the red errors):I think part of implementing this should be normalizing the way Twine reports warnings; it currently uses
logger.warning
andwarnings.warn
. It seems like the former is preferable for this purpose, althoughlogging.captureWarnings
could be a fallback.Similarly, we might want to rework the red error implementation from #649 to use
logger.error
.The text was updated successfully, but these errors were encountered: