Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
83da034c
Commit
83da034c
authored
Jun 11, 2009
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5262: Fixed bug in next roll over time computation in TimedRotatingFileHandler.
parent
c7498f5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
Lib/logging/handlers.py
Lib/logging/handlers.py
+10
-5
Misc/NEWS
Misc/NEWS
+12
-9
No files found.
Lib/logging/handlers.py
View file @
83da034c
...
@@ -204,7 +204,13 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -204,7 +204,13 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self
.
extMatch
=
re
.
compile
(
self
.
extMatch
)
self
.
extMatch
=
re
.
compile
(
self
.
extMatch
)
self
.
interval
=
self
.
interval
*
interval
# multiply by units requested
self
.
interval
=
self
.
interval
*
interval
# multiply by units requested
self
.
rolloverAt
=
currentTime
+
self
.
interval
self
.
rolloverAt
=
currentTime
+
self
.
interval
# If we are rolling over at midnight or weekly, then the interval is already known.
# What we need to figure out is WHEN the next interval is.
self
.
adjustRollover
(
currentTime
)
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
def
adjustRollover
(
self
,
currentTime
):
# If we are rolling over at midnight or weekly, then the interval is already known.
# If we are rolling over at midnight or weekly, then the interval is already known.
# What we need to figure out is WHEN the next interval is. In other words,
# What we need to figure out is WHEN the next interval is. In other words,
# if you are rolling over at midnight, then your base interval is 1 day,
# if you are rolling over at midnight, then your base interval is 1 day,
...
@@ -214,7 +220,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -214,7 +220,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
# the rest. Note that this code doesn't care about leap seconds. :)
# the rest. Note that this code doesn't care about leap seconds. :)
if
self
.
when
==
'MIDNIGHT'
or
self
.
when
.
startswith
(
'W'
):
if
self
.
when
==
'MIDNIGHT'
or
self
.
when
.
startswith
(
'W'
):
# This could be done with less code, but I wanted it to be clear
# This could be done with less code, but I wanted it to be clear
if
utc
:
if
self
.
utc
:
t
=
time
.
gmtime
(
currentTime
)
t
=
time
.
gmtime
(
currentTime
)
else
:
else
:
t
=
time
.
localtime
(
currentTime
)
t
=
time
.
localtime
(
currentTime
)
...
@@ -240,7 +246,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -240,7 +246,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
# The calculations described in 2) and 3) above need to have a day added.
# The calculations described in 2) and 3) above need to have a day added.
# This is because the above time calculation takes us to midnight on this
# This is because the above time calculation takes us to midnight on this
# day, i.e. the start of the next day.
# day, i.e. the start of the next day.
if
when
.
startswith
(
'W'
):
if
self
.
when
.
startswith
(
'W'
):
day
=
t
[
6
]
# 0 is Monday
day
=
t
[
6
]
# 0 is Monday
if
day
!=
self
.
dayOfWeek
:
if
day
!=
self
.
dayOfWeek
:
if
day
<
self
.
dayOfWeek
:
if
day
<
self
.
dayOfWeek
:
...
@@ -248,7 +254,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -248,7 +254,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else
:
else
:
daysToWait
=
6
-
day
+
self
.
dayOfWeek
+
1
daysToWait
=
6
-
day
+
self
.
dayOfWeek
+
1
newRolloverAt
=
self
.
rolloverAt
+
(
daysToWait
*
(
60
*
60
*
24
))
newRolloverAt
=
self
.
rolloverAt
+
(
daysToWait
*
(
60
*
60
*
24
))
if
not
utc
:
if
not
self
.
utc
:
dstNow
=
t
[
-
1
]
dstNow
=
t
[
-
1
]
dstAtRollover
=
time
.
localtime
(
newRolloverAt
)[
-
1
]
dstAtRollover
=
time
.
localtime
(
newRolloverAt
)[
-
1
]
if
dstNow
!=
dstAtRollover
:
if
dstNow
!=
dstAtRollover
:
...
@@ -258,8 +264,6 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -258,8 +264,6 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
newRolloverAt
=
newRolloverAt
+
3600
newRolloverAt
=
newRolloverAt
+
3600
self
.
rolloverAt
=
newRolloverAt
self
.
rolloverAt
=
newRolloverAt
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
def
shouldRollover
(
self
,
record
):
def
shouldRollover
(
self
,
record
):
"""
"""
Determine if rollover should occur.
Determine if rollover should occur.
...
@@ -341,6 +345,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -341,6 +345,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else
:
# DST bows out before next rollover, so we need to add an hour
else
:
# DST bows out before next rollover, so we need to add an hour
newRolloverAt
=
newRolloverAt
+
3600
newRolloverAt
=
newRolloverAt
+
3600
self
.
rolloverAt
=
newRolloverAt
self
.
rolloverAt
=
newRolloverAt
self
.
adjustRollover
(
time
.
time
())
class
WatchedFileHandler
(
logging
.
FileHandler
):
class
WatchedFileHandler
(
logging
.
FileHandler
):
"""
"""
...
...
Misc/NEWS
View file @
83da034c
...
@@ -317,6 +317,9 @@ Core and Builtins
...
@@ -317,6 +317,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #5262: Fixed bug in next rollover time computation in
TimedRotatingFileHandler.
- Issue #6263: Fixed syntax error in distutils.cygwincompiler.
- Issue #6263: Fixed syntax error in distutils.cygwincompiler.
- Issue #5201: distutils.sysconfig.parse_makefile() now understands `$$`
- Issue #5201: distutils.sysconfig.parse_makefile() now understands `$$`
...
@@ -351,7 +354,7 @@ Library
...
@@ -351,7 +354,7 @@ Library
- Issue #1424152: Fix for httplib, urllib2 to support SSL while working through
- Issue #1424152: Fix for httplib, urllib2 to support SSL while working through
proxy. Original patch by Christopher Li, changes made by Senthil Kumaran.
proxy. Original patch by Christopher Li, changes made by Senthil Kumaran.
- Issue #1983: Fix functions taking or returning a process identifier to use
- Issue #1983: Fix functions taking or returning a process identifier to use
the dedicated C type ``pid_t`` instead of a C ``int``. Some platforms have
the dedicated C type ``pid_t`` instead of a C ``int``. Some platforms have
a process identifier type wider than the standard C integer type.
a process identifier type wider than the standard C integer type.
...
@@ -359,7 +362,7 @@ Library
...
@@ -359,7 +362,7 @@ Library
- Issue #4066: smtplib.SMTP_SSL._get_socket now correctly returns the socket.
- Issue #4066: smtplib.SMTP_SSL._get_socket now correctly returns the socket.
Patch by Farhan Ahmad, test by Marcin Bachry.
Patch by Farhan Ahmad, test by Marcin Bachry.
- Issue #6062: In distutils, fixed the package option of build_ext. Feedback
- Issue #6062: In distutils, fixed the package option of build_ext. Feedback
and tests on pywin32 by Tim Golden.
and tests on pywin32 by Tim Golden.
- Issue #6053: Fixed distutils tests on win32. patch by Hirokazu Yamamoto.
- Issue #6053: Fixed distutils tests on win32. patch by Hirokazu Yamamoto.
...
@@ -367,7 +370,7 @@ Library
...
@@ -367,7 +370,7 @@ Library
- Issue #6046: Fixed the library extension when distutils build_ext is used
- Issue #6046: Fixed the library extension when distutils build_ext is used
inplace. Initial patch by Roumen Petrov.
inplace. Initial patch by Roumen Petrov.
- Issue #6041: Now distutils `sdist` and `register` commands use `check` as a
- Issue #6041: Now distutils `sdist` and `register` commands use `check` as a
subcommand.
subcommand.
- Issue #2116: Weak references and weak dictionaries now support copy()ing and
- Issue #2116: Weak references and weak dictionaries now support copy()ing and
...
@@ -517,8 +520,8 @@ Library
...
@@ -517,8 +520,8 @@ Library
- unittest.assertNotEqual() now uses the inequality operator (!=) instead
- unittest.assertNotEqual() now uses the inequality operator (!=) instead
of the equality operator.
of the equality operator.
- Issue #6001: Test discovery for unittest. Implemented in
- Issue #6001: Test discovery for unittest. Implemented in
unittest.TestLoader.discover and from the command line.
unittest.TestLoader.discover and from the command line.
- Issue #5679: The methods unittest.TestCase.addCleanup and doCleanups were added.
- Issue #5679: The methods unittest.TestCase.addCleanup and doCleanups were added.
...
@@ -528,11 +531,11 @@ Library
...
@@ -528,11 +531,11 @@ Library
- Issue #3379: unittest.main now takes an optional exit argument. If False main
- Issue #3379: unittest.main now takes an optional exit argument. If False main
doesn't call sys.exit allowing it to be used from the interactive interpreter.
doesn't call sys.exit allowing it to be used from the interactive interpreter.
- Issue #5995: unittest.main now takes an optional verbosity argument allowing
- Issue #5995: unittest.main now takes an optional verbosity argument allowing
test modules to be run with a higher than default verbosity.
test modules to be run with a higher than default verbosity.
- Issue #5995: A fix to allow you to run "python -m unittest test_module" or
- Issue #5995: A fix to allow you to run "python -m unittest test_module" or
"python -m unittest test_module.TestClass" from the command line.
"python -m unittest test_module.TestClass" from the command line.
- Issue #5728: unittest.TestResult has new startTestRun and stopTestRun methods;
- Issue #5728: unittest.TestResult has new startTestRun and stopTestRun methods;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment