You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Logger timestamp is off by up to one second when use_datetime_directive=True #8631
With use_datetime_directive=True, the timestamp key should show the time the log record was created, the same value the default formatting path shows.
Current Behaviour
The timestamp is shifted forward by the record's milliseconds. Whenever the sub second part is 500 ms or more, the seconds field is one second ahead, and %f shows the wrong microseconds.
For a record created at 1700000000.75 (17:13:20.750 UTC):
In LambdaPowertoolsFormatter.formatTime, the datetime directive branch builds the datetime from record.created + record.msecs / 1000. The comment says record.msecs is in microseconds, but it is the millisecond part of record.created (0 to 999), and record.created already includes the fractional second. The milliseconds are counted twice. Using record.created directly fixes it.
Steps to Reproduce
Run the snippet above, or log with Logger(datefmt="%H:%M:%S.%F", use_datetime_directive=True) and compare against the default timestamp.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation
Activity
boring-cyborg commentedon Oct 19, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
powertools-for-aws-oss-automation commentedon Oct 19, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation