Issue 22494: default logging time string is not localized (original) (raw)

Created on 2014-09-25 10:42 by sdague, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg227521 - (view) Author: Sean Dague (sdague) Date: 2014-09-25 10:42
The default time string is not localized for using locale specific formatting, but is instead hardcoded to a ','. https://hg.python.org/cpython/file/c87e00a6258d/Lib/logging/__init__.py#l483 demonstrates this. Instead I think we should set that to the value of: locale.localeconv()['decimal_point'] While this clearly a very minor issue, I stare at enough logging output data that falls back to default formats (due to testing environments) that would love for this to be locale aware.
msg228068 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-10-01 10:51
I'm a bit surprised here, since the comma is not the default (US) decimal point.
msg228069 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2014-10-01 11:49
It's not so surprising, since the string before the milliseconds part is a strftime() result, not a whole number. The decimal point need not necessarily be used for this. Just like the rest of the default time format, it is probably best for the millisecond part to be locale independent unless chosen to be locale aware by the programmer. Using the comma is apparently common among loggers. I've seen it in logs generated by log4j and log4cpp as well.
msg228070 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-10-01 11:57
ISO 8601 governs the format used. From the Wikipedia article on the same: "A decimal mark, either a comma or a dot (without any preference as stated in resolution 10 of the 22nd General Conference CGPM in 2003, but with a preference for a comma according to ISO 8601:2004) is used as a separator between the time element and its fraction."
History
Date User Action Args
2022-04-11 14:58:08 admin set github: 66684
2014-10-01 11:57:22 vinay.sajip set status: open -> closedresolution: not a bugmessages: +
2014-10-01 11:49:56 georg.brandl set nosy: + georg.brandlmessages: +
2014-10-01 10:51:39 pitrou set nosy: + pitroumessages: +
2014-09-25 18:46:00 ned.deily set nosy: + vinay.sajip
2014-09-25 10:42:32 sdague create