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
colorlog.LevelFormatter does not allow to use dict for fmt parameter on python 3.8 #77
Comments
Seems like Python-logging was updated in 3.8 with validation checks. Adding a validate=false flag into the logging.formatter initializer for Python >= 3.8 should fix it In my case, I just commented out the validate call in my logging lib. |
Could you provide a minimal code example you would expect to work? I'm very unclear on what usage would require passing a dictionary instead of a string as the |
The python-colorlog/colorlog/colorlog.py Lines 133 to 159 in 809e896
There's an example there. Perhaps it could be reworked to not store the dict into fmt, but that would seem like it's just a complicated way of bypassing the validation check. |
My mistake, it's a long time since I've looked at the code for |
Fix released as version 4.1.0: https://pypi.org/project/colorlog/4.1.0/ |
Traceback (most recent call last):
File "D:/gitrep/DevOpsCI/DiasoftBuild/DiasoftBuild.py", line 36, in
from LogInit import file_formatter
File "D:\gitrep\DevOpsCI\DiasoftBuild\CommonLib\LogInit.py", line 98, in
formatter = LevelFormatter(
File "C:\Users\panov-ea\AppData\Roaming\Python\Python38\site-packages\colorlog\colorlog.py", line 160, in init
super(LevelFormatter, self).init(
File "C:\Users\panov-ea\AppData\Roaming\Python\Python38\site-packages\colorlog\colorlog.py", line 91, in init
super(ColoredFormatter, self).init(fmt, datefmt, style)
File "C:\Users\panov-ea\AppData\Local\Programs\Python\Python38-32\lib\logging_init_.py", line 576, in init
self.style.validate()
File "C:\Users\panov-ea\AppData\Local\Programs\Python\Python38-32\lib\logging_init.py", line 456, in validate
for _, fieldname, spec, conversion in _str_formatter.parse(self._fmt):
File "C:\Users\panov-ea\AppData\Local\Programs\Python\Python38-32\lib\string.py", line 261, in parse
return _string.formatter_parser(format_string)
TypeError: expected str, got dict
The text was updated successfully, but these errors were encountered: