-
Notifications
You must be signed in to change notification settings - Fork 12
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
Added minimal logging #6
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels pretty essential - currently got a problem where having a logger would be handy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good addition, but I had two suggestions that block me from approving this PR. (you could always convince me, neither of them are [bug/blocking]
, much less [BLOCKING]
-- the latter of which I've only used twice when I ran into code that would instantly corrupt data)
@@ -268,6 +271,7 @@ def call(self, fn, *args, **kwargs): | |||
raise RetryError(attempt) | |||
else: | |||
sleep = self.wait(attempt_number, delay_since_first_attempt_ms) | |||
self._logger.info(f"Retrying in {sleep / 1000.0:.2f} seconds.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] This line should be below the if self._wait_jitter_max:
clause so that it reflects the actual wait time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: NM, I read it to quickly 😁. Moving below 👍
@@ -110,6 +111,7 @@ def __init__( | |||
self._wait_jitter_max = 0 if wait_jitter_max is None else wait_jitter_max | |||
self._before_attempts = before_attempts | |||
self._after_attempts = after_attempts | |||
self._logger = logging.getLogger(__name__) if logger is None else logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] This is okay, but I hate having a library change behavior wrt logging.
Maybe something like:
if logger in (True, None):
self._logger = logging.getLogger(__name__)
if logger is None:
# -- Turn this into a Null Logger
self._logger.addHandler(logging.NullHandler())
self._logger.propagate = False
elif logger:
self._logger = logger
Something like this for the issue #3 ?