Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Better use of UTC-based timing #8

Open
rickb777 opened this issue Apr 13, 2017 · 0 comments
Open

Better use of UTC-based timing #8

rickb777 opened this issue Apr 13, 2017 · 0 comments

Comments

@rickb777
Copy link

This is based on source code inspection of logging/logging.go.

Lines 59-61 get the time in the local timezone.

start := al.clock()
al.handler.ServeHTTP(wrapper, r)
end := al.clock()

Line 87 does a conversion to UTC

start.In(time.UTC).Format(apacheFormat),

and line 95 is

end.Sub(start).Nanoseconds()/int64(time.Millisecond)

There is a rare problem that the duration calculation will be in error when daylight saving turns on or off, for locales that have it. A simple solution might be to change lines 59 and 61

start := al.clock().UTC()
al.handler.ServeHTTP(wrapper, r)
end := al.clock().UTC()

and simplify line 87

start.Format(apacheFormat),
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant