-
Notifications
You must be signed in to change notification settings - Fork 704
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
Another way to set defaults #7
Comments
Oh, that's an edge case I did not think about, thanks for reporting it! I can see some ways to fix it without hacking inside Loguru internals. Simply set the environment variable programmatically using import os
os.environ["LOGURU_INFO_COLOR"] = ""
from loguru import logger But if you want to modify a Loguru default level from your script, better use the logger.level("INFO", color="") This can also be done with logger.configure(levels=[{"name": "INFO", "color": ""}]) However, this would mean that you have to repeat this inside all of your scripts. That is not very convenient at all. This is why environment variables are useful: set it once, and you're done. Therefore, a workaround has to be found. I guess that if the string is just a space like |
I like that because currently it just inserts a space and breaks all formatting. |
The recently published Don't hesitate to open a new issue if you encounter other troubles. 😉 |
Thanks for the update @Delgan! Works without issues. |
There needs to be another way to set defaults.
Environmental variables do not work for everything on Windows.
For example:
If I do not want any color for
INFO
level, I cannot set environment variableLOGURU_INFO_COLOR=""
because then it's disabled on Windows.I cannot do:
Since logger is already initialized.
Instead, I have to do extremely hacky stuff like:
Since
Level
is a namedtuple, I cannot even modify it in-placePerhaps a config file or an
.ini
file as well would be better.The text was updated successfully, but these errors were encountered: