Logger has [transformers] prefix in non-verbose mode#45316
Logger has [transformers] prefix in non-verbose mode#45316zucchini-nlp merged 6 commits intohuggingface:mainfrom
[transformers] prefix in non-verbose mode#45316Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
| if os.getenv("TRANSFORMERS_VERBOSITY", None) == "detail": | ||
| formatter = logging.Formatter("[%(levelname)s|%(pathname)s:%(lineno)s] %(asctime)s >> %(message)s") | ||
| _default_handler.setFormatter(formatter) | ||
| formatter = ColoredVerboseFormatter() |
There was a problem hiding this comment.
When logging happens in CI (see env flag below) we can probably keep a simple non-colored formatter to avoid weird console content in some UI
|
I have a bit of a personal dislike for colored logs, but that might just be me. I'll give this a better review on Friday. Please ping me if I forget. I'd like to check what happens with the Sentence Transformers logs that also rely on
|
|
Oh, I will revert the coloring. @tarekziade found that there's a no-color standard since 2017. Sure, will ping in Friday, maybe we could infer the "lib-name" in that case |
LysandreJik
left a comment
There was a problem hiding this comment.
Looks good! Agree that no color is better. Thanks @zucchini-nlp
|
Checked with ST and seems like the formatting isn't applied to logged messages from other libraries. Ig by the time ST imports the logger, we have already configured the handler and added it to root library's logger. Since we don't configure it second time, the formatter never gets added after that, even when the root library is different But we can be more careful and check library name when formattting. I'll push that and merge @tomaarsen |
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45316&sha=e2c345 |
|
Will give this a try on Monday! My apologies.
|
|
So far it seems to work okay. The transformers logs are nicely prefixed, and there's no prefixing for Sentence Transformers in my tests. It seems to be because there's already a default handler configured (i.e. the one for
|
|
Yep, and if there is somehow no default handler in other 3rd party libs, they will see their own lib-name prefixed 😄 I added a line to check the name first |
…5316) * . * wait * no color * oops * lib name is not hardcoded anymore
What does this PR do?
As per title and seems like there are no objections. Also added some colors in verbose logging
cc @tarekziade @tomaarsen @yonigozlan if you have better ideas to style this (just tagging since you reacted ➕ )
This is how it looks like by default:

This is how it looks like when verbose:
