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
0f15181d
Commit
0f15181d
authored
Mar 13, 2012
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Closes #14267: Merged fix from 3.2.
parents
4bd53b13
27f48979
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
Lib/logging/handlers.py
Lib/logging/handlers.py
+15
-6
No files found.
Lib/logging/handlers.py
View file @
0f15181d
...
...
@@ -305,9 +305,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
dstAtRollover
=
time
.
localtime
(
newRolloverAt
)[
-
1
]
if
dstNow
!=
dstAtRollover
:
if
not
dstNow
:
# DST kicks in before next rollover, so we need to deduct an hour
newRolloverAt
=
newRolloverAt
-
3600
addend
=
-
3600
else
:
# DST bows out before next rollover, so we need to add an hour
newRolloverAt
=
newRolloverAt
+
3600
addend
=
3600
newRolloverAt
+=
addend
result
=
newRolloverAt
return
result
...
...
@@ -358,11 +359,20 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self
.
stream
.
close
()
self
.
stream
=
None
# get the time that this sequence started at and make it a TimeTuple
currentTime
=
int
(
time
.
time
())
dstNow
=
time
.
localtime
(
currentTime
)[
-
1
]
t
=
self
.
rolloverAt
-
self
.
interval
if
self
.
utc
:
timeTuple
=
time
.
gmtime
(
t
)
else
:
timeTuple
=
time
.
localtime
(
t
)
dstThen
=
timeTuple
[
-
1
]
if
dstNow
!=
dstThen
:
if
dstNow
:
addend
=
3600
else
:
addend
=
-
3600
timeTuple
=
time
.
localtime
(
t
+
addend
)
dfn
=
self
.
rotation_filename
(
self
.
baseFilename
+
"."
+
time
.
strftime
(
self
.
suffix
,
timeTuple
))
if
os
.
path
.
exists
(
dfn
):
...
...
@@ -373,19 +383,18 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
os
.
remove
(
s
)
self
.
mode
=
'w'
self
.
stream
=
self
.
_open
()
currentTime
=
int
(
time
.
time
())
newRolloverAt
=
self
.
computeRollover
(
currentTime
)
while
newRolloverAt
<=
currentTime
:
newRolloverAt
=
newRolloverAt
+
self
.
interval
#If DST changes and midnight or weekly rollover, adjust for this.
if
(
self
.
when
==
'MIDNIGHT'
or
self
.
when
.
startswith
(
'W'
))
and
not
self
.
utc
:
dstNow
=
time
.
localtime
(
currentTime
)[
-
1
]
dstAtRollover
=
time
.
localtime
(
newRolloverAt
)[
-
1
]
if
dstNow
!=
dstAtRollover
:
if
not
dstNow
:
# DST kicks in before next rollover, so we need to deduct an hour
newRolloverAt
=
newRolloverAt
-
3600
addend
=
-
3600
else
:
# DST bows out before next rollover, so we need to add an hour
newRolloverAt
=
newRolloverAt
+
3600
addend
=
3600
newRolloverAt
+=
addend
self
.
rolloverAt
=
newRolloverAt
class
WatchedFileHandler
(
logging
.
FileHandler
):
...
...
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