Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add milliseconds to --log entry timestamps. #6621

Merged
merged 3 commits into from
Jun 17, 2019

Conversation

chrahunt
Copy link
Member

Resolves #6587.

else:
t = time.strftime(self.default_time_format, ct)
s = self.default_msec_format % (t, record.msecs)
return s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this was the concern I expressed here and that @pfmoore seemed to agree with: #6587 (comment)

For comparison, how simple could the PR look if only Python versions that have the feature out of the box got the enhancement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would it solve things just to use the logging module's default datefmt? It looks like that code path uses milliseconds even in Python 2 when I checked.

Copy link
Member Author

@chrahunt chrahunt Jun 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using default_time_format only for Python 3 would require at least 1 check in format and several in the tests. I updated the PR with a simpler approach that still works for both 2 and 3 and removes this block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read my second comment, too. I don’t see a reply to that.

Copy link
Member Author

@chrahunt chrahunt Jun 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I hadn't refreshed the page when I had posted.

Regarding datefmt, I see it passed to formatTime by the Formatter.format method only if we use %(asctime) in the general formatter format string (1) and if it is passed to formatTime and is truthy then it bypasses the millisecond formatting (2). So I don't think it will work for us here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you understood my suggestion. I was suggesting changing self.formatTime(record, "%Y-%m-%dT%H:%M:%S") to self.formatTime(record) in order to use the logging module's default format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right I misunderstood. I prefer the current format since it is standard and if parsing would be easier to split(1) for each line of the log records. When we drop 2 support this can be cleaned up as in the initial revision (with default_time_format) while preserving the same format, but I suspect there will be a lot more refactoring in a lot more places when that happens.

@chrahunt chrahunt force-pushed the feature/log-milliseconds branch from 4207255 to eec53cc Compare June 16, 2019 22:25
@cjerdonek
Copy link
Member

cjerdonek commented Jun 16, 2019 via email

@chrahunt
Copy link
Member Author

TODO added.

Copy link
Member

@cjerdonek cjerdonek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@cjerdonek cjerdonek merged commit 26cdedd into pypa:master Jun 17, 2019
@chrahunt chrahunt deleted the feature/log-milliseconds branch June 17, 2019 23:55
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jul 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include milliseconds in pip log timestamps
3 participants