logging.LogRecord asctime aattribute - easily override somehow?

Skip Montanaro skip.montanaro at gmail.com
Wed Mar 29 17:49:44 EDT 2017


Skip> Whoever thought you'd want to break up
Skip> timestamps into two words by default, and hard-code a comma as the
Skip> separator between seconds and milliseconds?

Peter> In Germany the comma is the decimal separator, so this doesn't
look like two
Peter> words to my eye.

The "two words" reference I made was to the space separating the date
and time. (I'd prefer a "T" separating date and time, as downstream
log processing tools can be slightly simpler, since they don't have to
collapse two fields into one.) The comma separator in the seconds
field is fine if that's appropriate for your environment, though it
appears to be hard-coded, not locale-specific:

    default_time_format = '%Y-%m-%d %H:%M:%S'
    default_msec_format = '%s,%03d'

If I parse such times in a straightforward way in my locale (C or
en_US.utf8), extracting the seconds as a floating point number is,
once again, more complex than it ought to be, as a comma is not the
proper decimal point in my locale(s).

Skip


More information about the Python-list mailing list