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
0b7609e2
Commit
0b7609e2
authored
Oct 03, 2004
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes made to maintain 1.5.2 compatibility.
parent
38f557f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
Lib/logging/handlers.py
Lib/logging/handlers.py
+27
-6
No files found.
Lib/logging/handlers.py
View file @
0b7609e2
...
@@ -182,7 +182,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -182,7 +182,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else
:
else
:
raise
ValueError
(
"Invalid rollover interval specified: %s"
%
self
.
when
)
raise
ValueError
(
"Invalid rollover interval specified: %s"
%
self
.
when
)
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.
# If we are rolling over at midnight or weekly, then the interval is already known.
...
@@ -200,8 +200,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -200,8 +200,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
currentSecond
=
t
[
5
]
currentSecond
=
t
[
5
]
# r is the number of seconds left between now and midnight
# r is the number of seconds left between now and midnight
r
=
(
24
-
currentHour
)
*
60
*
60
# number of hours in seconds
r
=
(
24
-
currentHour
)
*
60
*
60
# number of hours in seconds
r
+=
(
59
-
currentMinute
)
*
60
# plus the number of minutes (in secs)
r
=
r
+
(
59
-
currentMinute
)
*
60
# plus the number of minutes (in secs)
r
+=
(
59
-
currentSecond
)
# plus the number of seconds
r
=
r
+
(
59
-
currentSecond
)
# plus the number of seconds
self
.
rolloverAt
=
currentTime
+
r
self
.
rolloverAt
=
currentTime
+
r
# If we are rolling over on a certain day, add in the number of days until
# If we are rolling over on a certain day, add in the number of days until
# the next rollover, but offset by 1 since we just calculated the time
# the next rollover, but offset by 1 since we just calculated the time
...
@@ -219,10 +219,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
...
@@ -219,10 +219,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
day
=
t
[
6
]
# 0 is Monday
day
=
t
[
6
]
# 0 is Monday
if
day
>
self
.
dayOfWeek
:
if
day
>
self
.
dayOfWeek
:
daysToWait
=
(
day
-
self
.
dayOfWeek
)
-
1
daysToWait
=
(
day
-
self
.
dayOfWeek
)
-
1
self
.
rolloverAt
+=
(
daysToWait
*
(
60
*
60
*
24
))
self
.
rolloverAt
=
self
.
rolloverAt
+
(
daysToWait
*
(
60
*
60
*
24
))
if
day
<
self
.
dayOfWeek
:
if
day
<
self
.
dayOfWeek
:
daysToWait
=
(
6
-
self
.
dayOfWeek
)
+
day
daysToWait
=
(
6
-
self
.
dayOfWeek
)
+
day
self
.
rolloverAt
+=
(
daysToWait
*
(
60
*
60
*
24
))
self
.
rolloverAt
=
self
.
rolloverAt
+
(
daysToWait
*
(
60
*
60
*
24
))
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
...
@@ -656,6 +656,24 @@ class SMTPHandler(logging.Handler):
...
@@ -656,6 +656,24 @@ class SMTPHandler(logging.Handler):
"""
"""
return
self
.
subject
return
self
.
subject
weekdayname
=
[
'Mon'
,
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
,
'Sat'
,
'Sun'
]
monthname
=
[
None
,
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
]
def
date_time
(
self
):
"""
Return the current date and time formatted for a MIME header.
Needed for Python 1.5.2 (no email package available)
"""
year
,
month
,
day
,
hh
,
mm
,
ss
,
wd
,
y
,
z
=
time
.
gmtime
(
time
.
time
())
s
=
"%s, %02d %3s %4d %02d:%02d:%02d GMT"
%
(
self
.
weekdayname
[
wd
],
day
,
self
.
monthname
[
month
],
year
,
hh
,
mm
,
ss
)
return
s
def
emit
(
self
,
record
):
def
emit
(
self
,
record
):
"""
"""
Emit a record.
Emit a record.
...
@@ -664,7 +682,10 @@ class SMTPHandler(logging.Handler):
...
@@ -664,7 +682,10 @@ class SMTPHandler(logging.Handler):
"""
"""
try
:
try
:
import
smtplib
import
smtplib
from
email.Utils
import
formatdate
try
:
from
email.Utils
import
formatdate
except
:
formatdate
=
self
.
date_time
port
=
self
.
mailport
port
=
self
.
mailport
if
not
port
:
if
not
port
:
port
=
smtplib
.
SMTP_PORT
port
=
smtplib
.
SMTP_PORT
...
...
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