Message344110
> Doing something as basic as logging unicode shouldn't require knowledge of "handlers" - that's failing "simple is better than complex".
I reiterate my statement that it appears that you aren't sufficiently familiar with how logging is designed to work. Logging is more complex than print() or open() because it has to work flexibly in lots of different scenarios. Handlers are part of this, as are Formatters and Filters.
See my 2009 blog post
https://plumberjack.blogspot.com/2009/09/python-logging-101.html
for more information for why logging is designed the way it is.
If you want to configure a stream with utf-8 encoding, without explicitly using handlers, this is easily doable, as follows:
C:\Users\Vinay> \python37\python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.basicConfig(stream=open(r'c:\temp\my_log.log', 'w', encoding='utf-8'))
>>> logging.error('จุด1')
>>> ^Z
and, lo and behold, the file c:\temp\my_log.log contains
ERROR:root:จุด1
The use of the stream keyword parameter is clearly documented at
https://docs.python.org/3/library/logging.html#logging.basicConfig
Did you look at the basicConfig documentation before raising this issue? |
|
Date |
User |
Action |
Args |
2019-05-31 19:33:50 | vinay.sajip | set | recipients:
+ vinay.sajip, paul.moore, tim.golden, SilentGhost, zach.ware, steve.dower, jonathan-lp |
2019-05-31 19:33:50 | vinay.sajip | set | messageid: <1559331230.68.0.163862353268.issue37111@roundup.psfhosted.org> |
2019-05-31 19:33:50 | vinay.sajip | link | issue37111 messages |
2019-05-31 19:33:50 | vinay.sajip | create | |
|