Skip to content

Conversation

@Malayke
Copy link
Contributor

@Malayke Malayke commented Oct 4, 2025

This pull request fixes a bug that caused an AttributeError: module 'datetime' has no attribute 'now' when initializing logging in verbose mode.

The error occurred because the code was incorrectly calling datetime.now() instead of the correct datetime.datetime.now().

This change updates the method call to correctly reference the datetime class within the datetime module, ensuring that the timestamp for the log filename is generated without errors.


if self.verbose:
log_filename = self.log_filename or datetime.now().strftime(
log_filename = self.log_filename or datetime.datetime.now().strftime(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for noticing the problem.
I would like make it add:
from datetime import datetime
at the top of the file instead of datetime.datetime.now()
what do you think about the change?

@tavallaie
Copy link
Collaborator

Also maybe it in not a bad idea to separate logger logic from the rest of the modules.
@ChuckHend what do you think about this change?

@ChuckHend
Copy link
Contributor

Also maybe it in not a bad idea to separate logger logic from the rest of the modules. @ChuckHend what do you think about this change?

I think that makes sense. It would be great if logging became overall easier to configure too. But that should be done in another PR. I think this one is good to go.

@tavallaie
Copy link
Collaborator

So for now, I also approved it. I will make another PR for logging.

@tavallaie tavallaie merged commit 99fe29b into pgmq:main Oct 11, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants