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
f297bd19
Commit
f297bd19
authored
Apr 23, 2003
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch #725904, Minor changes to logging from module author (Vinay Sajip)
- upgrade to version 0.4.8
parent
11b23069
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
Lib/logging/__init__.py
Lib/logging/__init__.py
+2
-9
Lib/logging/handlers.py
Lib/logging/handlers.py
+29
-7
No files found.
Lib/logging/__init__.py
View file @
f297bd19
...
@@ -35,21 +35,14 @@ except ImportError:
...
@@ -35,21 +35,14 @@ except ImportError:
thread
=
None
thread
=
None
__author__
=
"Vinay Sajip <vinay_sajip@red-dove.com>"
__author__
=
"Vinay Sajip <vinay_sajip@red-dove.com>"
__status__
=
"
alph
a"
__status__
=
"
bet
a"
__version__
=
"0.4.8"
__version__
=
"0.4.8"
__date__
=
"
16 February
2003"
__date__
=
"
22 April
2003"
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Miscellaneous module data
# Miscellaneous module data
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
#
# _verinfo is used for when behaviour needs to be adjusted to the version
# of Python
#
_verinfo
=
getattr
(
sys
,
"version_info"
,
None
)
#
#
#_srcfile is used when walking the stack to check when we've got the first
#_srcfile is used when walking the stack to check when we've got the first
# caller stack frame.
# caller stack frame.
...
...
Lib/logging/handlers.py
View file @
f297bd19
...
@@ -26,7 +26,7 @@ Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
...
@@ -26,7 +26,7 @@ Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
To use, simply 'import logging' and log away!
"""
"""
import
sys
,
logging
,
socket
,
types
,
os
,
string
,
cPickle
,
struct
import
sys
,
logging
,
socket
,
types
,
os
,
string
,
cPickle
,
struct
,
time
from
SocketServer
import
ThreadingTCPServer
,
StreamRequestHandler
from
SocketServer
import
ThreadingTCPServer
,
StreamRequestHandler
...
@@ -145,8 +145,7 @@ class SocketHandler(logging.Handler):
...
@@ -145,8 +145,7 @@ class SocketHandler(logging.Handler):
This function allows for partial sends which can happen when the
This function allows for partial sends which can happen when the
network is busy.
network is busy.
"""
"""
v
=
logging
.
_verinfo
if
hasattr
(
self
.
sock
,
"sendall"
):
if
v
and
(
v
[
0
]
>=
2
)
and
(
v
[
1
]
>=
2
):
self
.
sock
.
sendall
(
s
)
self
.
sock
.
sendall
(
s
)
else
:
else
:
sentsofar
=
0
sentsofar
=
0
...
@@ -448,6 +447,21 @@ class SMTPHandler(logging.Handler):
...
@@ -448,6 +447,21 @@ 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."""
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.
...
@@ -461,11 +475,11 @@ class SMTPHandler(logging.Handler):
...
@@ -461,11 +475,11 @@ class SMTPHandler(logging.Handler):
port
=
smtplib
.
SMTP_PORT
port
=
smtplib
.
SMTP_PORT
smtp
=
smtplib
.
SMTP
(
self
.
mailhost
,
port
)
smtp
=
smtplib
.
SMTP
(
self
.
mailhost
,
port
)
msg
=
self
.
format
(
record
)
msg
=
self
.
format
(
record
)
msg
=
"From: %s
\
r
\
n
To: %s
\
r
\
n
Subject: %s
\
r
\
n
\
r
\
n
%s"
%
(
msg
=
"From: %s
\
r
\
n
To: %s
\
r
\
n
Subject: %s
\
r
\
n
Date: %s
\
r
\
n
\
r
\
n
%s"
%
(
self
.
fromaddr
,
self
.
fromaddr
,
string
.
join
(
self
.
toaddrs
,
","
),
string
.
join
(
self
.
toaddrs
,
","
),
self
.
getSubject
(
record
),
msg
self
.
getSubject
(
record
),
)
self
.
date_time
(),
msg
)
smtp
.
sendmail
(
self
.
fromaddr
,
self
.
toaddrs
,
msg
)
smtp
.
sendmail
(
self
.
fromaddr
,
self
.
toaddrs
,
msg
)
smtp
.
quit
()
smtp
.
quit
()
except
:
except
:
...
@@ -587,6 +601,14 @@ class HTTPHandler(logging.Handler):
...
@@ -587,6 +601,14 @@ class HTTPHandler(logging.Handler):
self
.
url
=
url
self
.
url
=
url
self
.
method
=
method
self
.
method
=
method
def
mapLogRecord
(
self
,
record
):
"""
Default implementation of mapping the log record into a dict
that is send as the CGI data. Overwrite in your class.
Contributed by Franz Glasner.
"""
return
record
.
__dict__
def
emit
(
self
,
record
):
def
emit
(
self
,
record
):
"""
"""
Emit a record.
Emit a record.
...
@@ -597,7 +619,7 @@ class HTTPHandler(logging.Handler):
...
@@ -597,7 +619,7 @@ class HTTPHandler(logging.Handler):
import
httplib
,
urllib
import
httplib
,
urllib
h
=
httplib
.
HTTP
(
self
.
host
)
h
=
httplib
.
HTTP
(
self
.
host
)
url
=
self
.
url
url
=
self
.
url
data
=
urllib
.
urlencode
(
record
.
__dict__
)
data
=
urllib
.
urlencode
(
self
.
mapLogRecord
(
record
)
)
if
self
.
method
==
"GET"
:
if
self
.
method
==
"GET"
:
if
(
string
.
find
(
url
,
'?'
)
>=
0
):
if
(
string
.
find
(
url
,
'?'
)
>=
0
):
sep
=
'&'
sep
=
'&'
...
...
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