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
scy
Als Antwort auf scy • • •Also, this was painful to read.
docs.python.org/3/library/logg…
#Python #logging
logging — Logging facility for Python
Python documentationDaniel Bohrer
Als Antwort auf scy • • •scy
Als Antwort auf Daniel Bohrer • • •I don't really understand why they're not doing it (didn't take the time to read up on it either though), but yeah.
Note however that strptime has %f, but strftime doesn't:
docs.python.org/3/library/time…
And all of these just apply to the `time` module, not to `datetime`, which has a different implementation of strftime that _also_ supports %f.
docs.python.org/3/library/date…
Which means that I'll use datetime instead and be okay:
chaos.social/@scy/114359324930…
time — Time access and conversions
Python documentationI don't really understand why they're not doing it (didn't take the time to read up on it either though), but yeah.
Note however that strptime has %f, but strftime doesn't:
docs.python.org/3/library/time…
And all of these just apply to the `time` module, not to `datetime`, which has a different implementation of strftime that _also_ supports %f.
docs.python.org/3/library/date…
Which means that I'll use datetime instead and be okay:
chaos.social/@scy/114359324930…
scy
2025-04-18 14:00:16
Fink
Als Antwort auf scy • • •RFC 3339 ftw
And yes 🫠
ijmacd.github.io/rfc3339-iso86…
RFC 3339 vs ISO 8601
ijmacd.github.ioscy
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
Paul McGuire
Als Antwort auf scy • • •