Ticket #867 (closed enhancement: fixed )

Opened 4 years ago

Last modified 2 years ago

Improvements to logging timestamp

Reported by: itamarst Assigned to: therve
Type: enhancement Priority: highest
Milestone: Component: core
Keywords: Cc: exarkun, itamarst, anthony, jknight, therve, jerub
Branch: Author:
Launchpad Bug:

Attachments

867_log.diff (3.1 kB) - added by therve 3 years ago.

Change History

  2005-01-20 22:37:02+00:00 changed by itamarst

Anthony wanted to add seconds timestamps, and I agree this is a good idea. His
suggestion was using ISO 8601 timestamps as a standard format
(http://www.cl.cam.ac.uk/~mgk25/iso-time.html).
With seconds and local timezone, format would be:
2005-01-20T11:30:20-0500
For comparision, current format is:
2005/01/20 11:32 EST
or sometimes (on Windows):
2005/01/20 11:32 Eastern Standard Time
so this would be 4 extra characters per message (on non-broken platforms).
Simply adding seconds to current format is 3 extra characters, so I think that's
reasonable.
This solves:
1. Lack of resolution in current format.
2. Really really really long timezone names on Windows.
3. Ambiguity of timezone regarding daylight savings time.

  2005-01-25 02:37:36+00:00 changed by itamarst

There's code for doing ISO 8601 in xml.utils.iso8601. This is going to be sucky
and slow, I can tell already, until we make twisted have efficient "get the
current second" code  or something :(

  2005-01-25 11:09:05+00:00 changed by jknight

1) ISO8601 format is usually spelled without a T in the middle when meant
for human readability. That is, an ISO8601 date and an ISO8601 time,
separated by a space, instead of an ISO8601 combined datetime.
"2005-01-20 11:30:20-0500".
2) It's too bad %z in strftime isn't standard (or else that python doesn't
just implement its own strftime instead of using the OS's), because then a
good format would be "%Y-%m-%D %H:%M:%S%z", and would allow the code and
behavior to not be changed, just the default format string.

  2006-08-26 11:47:11+00:00 changed by therve

  • cc changed from exarkun, itamarst, anthony, jknight to exarkun, itamarst, anthony, jknight, therve
  • keywords set to review

It seems the timezone problem has already been fixed. Attached a patch adding seconds and changing date separators to '-'.

  2006-08-26 14:58:03+00:00 changed by exarkun

Still dislike this solution. The real problem is that setting the format from outside Twisted is hard. That's what should be fixed.

  2006-08-28 15:09:20+00:00 changed by therve

I can't agree more. But I thought it was beyond the scope of this ticket, which just talks about the default format used.

The best way for me to customize the format is to subclass FileLogObserver and to make t.p.log uses it: very easy if you don't use twistd. The real problem is setting the format inside twistd :).

  2006-09-16 08:05:11+00:00 changed by jml

  • priority changed from normal to highest

  2006-09-18 12:27:43+00:00 changed by jerub

  • keywords deleted
  • owner changed from itamarst to therve

These strings are almost but not quite ISO8601.

"2001-02-02 23:05:06 -0500"
vs.
"2001-02-02 23:05:06-0500"

The docstring says: "human-readable string", update this to say, "ISO8601 string", and and please update the strings to be valid ISO8601 strings, then you may merge.

  2006-09-18 13:12:14+00:00 changed by therve

  • attachment 867_log.diff added

  2006-09-18 13:14:13+00:00 changed by therve

  • keywords set to review

OK I updated the patch according to your comments. I tried to be more explicit in the docstring, and changed the timestamp position (note that's still not ISO8601, as jknight pointed out).

  2006-09-19 23:52:57+00:00 changed by jerub

  • cc changed from exarkun, itamarst, anthony, jknight, therve to exarkun, itamarst, anthony, jknight, therve, jerub
  • keywords deleted

Facinating. I always considered the 'T' optional, but according to the sources I just read, it's valid to omit it, but you change the meaning. When you omit the 'T' and use a ' ' instead, you're actually putting an ISO8601 date next to an ISO8601 time, which isn't the same thing as having an ISO8601 datetime. How schizophrenic.

Oh well, mx.Datetime.ISO.ParseAny() pulls it in fine, so that's good enough for me.

I'm satisfied with this patch, please commit to trunk. Please make a note in your commit message intended for the release manager what the old format was and what the new format is. This will be important information for the release notes (someone, somewhere, might rely on the old timestamp format).

  2006-09-20 07:03:30+00:00 changed by therve

  • owner deleted

  2006-11-01 15:50:44+00:00 changed by exarkun

  • priority changed from highest to normal

I think this basically addresses #880 as well. However, I think the nasty crud in conch should be removed as part of this change as well (so I am not applying the patch now).

I'll probably get to the conch stuff soon, but if anyone feels like beating me to it...

  2006-11-02 20:44:12+00:00 changed by therve

For the conch stuff, you're talking about _LogTimeFormatMixin in test_ssh ? If it's that I can update the patch with its removal, it doesn't seem to have to much impact.

  2006-11-02 21:39:19+00:00 changed by exarkun

Yea, that's what I mean.

Jerub has been threatening to actually fix this issue, though, by making it possible to configure logging on the twistd command line. If he makes makes any progress on that it might be a good idea to include this change as a part of that one. I generally like to keep changes as separate and tiny as possible, but with actual configurability, there wouldn't even need to be a change to the default logging format.

  2007-01-19 22:07:46+00:00 changed by therve

  • keywords set to review
  • priority changed from normal to highest

As I didn't get news from something into twistd, I went on and cleaned some stuff.

Ready to review in improve-log-867.

  2007-01-27 14:47:48+00:00 changed by exarkun

  • keywords deleted
  • owner set to therve

I reflowed the part of the formatTime docstring which talks about ISO8601, since it looked wierd.

Everything else in this branch looks great. Please merge it.

  2007-01-27 16:27:21+00:00 changed by therve

  • status changed from new to closed
  • resolution set to fixed

(In [19485]) Merge improve-log-867

Author: therve Reviewer: exarkun Fixes #867

Add seconds to default log format, for using ISO8601 date and an ISO8601 time. In the process some cleanups have been made.

People relying on the old default format (to parse log for example) should be warned.

Note: See TracTickets for help on using tickets.