-
-
Notifications
You must be signed in to change notification settings - Fork 32k
TimedRotatingFileHandler "midnight" misleading when interval > 1 #90535
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
Comments
Using the TimedRotatingFileHandler along with "when='midnight'" and interval > 1, midnight is handled equally to "days" which is a little misleading. Expectation: Current behavior: In my case, this led to some unforeseeable and unexpected behavior. |
Making a change without considering backward compatibility is premature. I've closed the PR as there appears to be something wrong with it - it references hundreds of changed files. Did you look at the 'atTime' keyword parameter of TimedRotatingFileHandler? |
i've just checked PR and you're right, something with the PR went wrong. Anyway, midnight (at least from the wording) specifies the "atTime". (which should be midnight). Again, if there's (by mistake) an interval bigger than 1 set(which in my mind makes no sense along to be used with midnight) things are getting pretty intransparent. The midnight handler created a logfile dated with 2021-12-15 (last night). Took me some time to get this sorted. (I've discovered, that I've set 30 in a default value file). Agreed on the backward compatibility, but I would assume someone using "midnight" would not expect any other behavior than "daily at midnight" besides using the atTime to modify the rollover time. (my opinion) |
Unfortunately, you can't rely on people always doing "the sensible thing", for any number of good reasons. If a particular set of parameter values didn't cause failure, it is probably used somewhere. Anyway, your problem goes away if interval == 1, right? If we were to tighten things up (e.g. disallowing interval > 1 with "midnight"), then it would have to be done on a deprecation cycle at the very least, ISTM. |
Yes, enforcing interval == 1 or interval == None (which pulls the TimedRotatingFileHandler class __init__ default value which is also 1) works perfectly with midnight. I do not see any urge on that topic - as I personally now know the issue :D - but I really feel this fix could save someones else's time someday ;) So going the "safe" way via deprecation cycle seems to be the right approach |
I see now that the problem is that My fix #116191 perhaps affected this issue and made it worse (if you do not consider it better). Previously, in Perhaps the safest way is to implement the correct support of the |
…eHandler Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…er (GH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <[email protected]>
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <[email protected]>
…leHandler (GH-116220) (GH-116892) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <[email protected]>
…leHandler (GH-116220) (GH-116893) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <[email protected]>
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
when='MIDNIGHT'
#98099The text was updated successfully, but these errors were encountered: