Skip to content

Yagna datetime format in logs#463

Merged
azawlocki merged 5 commits intob0.6from
az/yagna-datetime-format
Jun 17, 2021
Merged

Yagna datetime format in logs#463
azawlocki merged 5 commits intob0.6from
az/yagna-datetime-format

Conversation

@azawlocki
Copy link
Contributor

Resolves #388

Example log line after the changes in this PR:

[2021-06-11T14:54:54.734.995+0200 DEBUG yapapi] Yapapi version: 0.6.0-alpha.1, script: examples/three_clusters.py, working directory: /home/azawlocki/golem/yapapi

@azawlocki azawlocki requested a review from a team June 14, 2021 11:34
@azawlocki azawlocki changed the title Az/yagna datetime format Yagna datetime format in logs Jun 14, 2021
@azawlocki azawlocki changed the base branch from master to b0.6 June 14, 2021 11:58
yapapi/log.py Outdated
Comment on lines +73 to +75
"""Format datetime; example: `2021-06-11T14:55:43.156.123+0200`."""
dt = datetime.fromtimestamp(record.created, tz=self.LOCAL_TZ)
return dt.strftime(f"%Y-%m-%dT%H:%M:%S.{dt.microsecond / 1000}%z")
Copy link
Contributor

@filipgolem filipgolem Jun 16, 2021

Choose a reason for hiding this comment

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

There is no need to display microseconds.

Suggested change
"""Format datetime; example: `2021-06-11T14:55:43.156.123+0200`."""
dt = datetime.fromtimestamp(record.created, tz=self.LOCAL_TZ)
return dt.strftime(f"%Y-%m-%dT%H:%M:%S.{dt.microsecond / 1000}%z")
"""Format datetime; example: `2021-06-11T14:55:43.156+0200`."""
dt = datetime.fromtimestamp(record.created, tz=self.LOCAL_TZ)
return dt.strftime(f"%Y-%m-%dT%H:%M:%S.{int(dt.microsecond / 1000)}%z")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @filipgolem, good catch! And I need also to remember about the leading 0's, in case the number of milliseconds is less than 100.

@azawlocki azawlocki force-pushed the az/yagna-datetime-format branch from aef174b to 3ba6a65 Compare June 17, 2021 07:06
@azawlocki azawlocki merged commit 7beca1c into b0.6 Jun 17, 2021
@shadeofblue shadeofblue deleted the az/yagna-datetime-format branch September 13, 2021 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ensure that the logs contain the TZ offset

3 participants