Zum Inhalt der Seite gehen


Python: *has very flexible logging system*

also Python: *has no format string placeholder for fractional seconds*

me, wanting a ISO 8601 compatible timestamp with milliseconds in his logs:

[Edit: fixed and improved version in the replies]

#Python #logging #ISO8601

Dieser Beitrag wurde bearbeitet. (1 Tag her)
Als Antwort auf scy

Also, this was painful to read.

docs.python.org/3/library/logg…

#Python #logging

Als Antwort auf scy

ouch… I guess changing the stdlib to introduce a new millisecond value for strptime is a no-go
Als Antwort auf Daniel Bohrer

Dieser Beitrag wurde bearbeitet. (1 Tag her)
Als Antwort auf scy

Okay, yeah, so, that method was BS for two reasons: I'm formatting the milliseconds from the log record, but the rest of the timestamp from "now" (lol, ouch) – but also, the underlying problem is using time.strftime (like the base class) instead of the more modern datetime.datetime.strftime. Because the latter actually _does_ have a format string placeholder for microseconds (not milliseconds though).

So, after a bit of iteration, I think I'll be going with this one:

#Python #logging

Dieser Beitrag wurde bearbeitet. (1 Tag her)
Als Antwort auf scy

The only way I've found to format time to milliseconds is to use a `[:23]` slice.