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
8dd8d582
Commit
8dd8d582
authored
Jun 09, 2011
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Merged fix for issue #12168 from 3.2.
parents
d9463b23
8168d10e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
Lib/logging/handlers.py
Lib/logging/handlers.py
+5
-1
Lib/test/test_logging.py
Lib/test/test_logging.py
+6
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/logging/handlers.py
View file @
8dd8d582
...
...
@@ -769,6 +769,8 @@ class SysLogHandler(logging.Handler):
"""
return
self
.
priority_map
.
get
(
levelName
,
"warning"
)
append_nul
=
True
# some old syslog daemons expect a NUL terminator
def
emit
(
self
,
record
):
"""
Emit a record.
...
...
@@ -776,7 +778,9 @@ class SysLogHandler(logging.Handler):
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
"""
msg
=
self
.
format
(
record
)
+
'
\
000
'
msg
=
self
.
format
(
record
)
if
self
.
append_nul
:
msg
+=
'
\
000
'
"""
We need to convert record level to lowercase, maybe this will
change in the future.
...
...
Lib/test/test_logging.py
View file @
8dd8d582
...
...
@@ -1399,8 +1399,7 @@ class DatagramHandlerTest(BaseTest):
pointing to that server's address and port."""
BaseTest.setUp(self)
addr = ('localhost', 0)
self.server = server = TestUDPServer(addr, self.handle_datagram,
0.01)
self.server = server = TestUDPServer(addr, self.handle_datagram, 0.01)
server.start()
server.ready.wait()
self.sock_hdlr = logging.handlers.DatagramHandler('localhost',
...
...
@@ -1478,6 +1477,11 @@ class SysLogHandlerTest(BaseTest):
logger.error("
sp
\
xe4m
")
self.handled.wait()
self.assertEqual(self.log_output, b'<11>
\
xef
\
xbb
\
xbf
sp
\
xc3
\
xa4
m
\
x00
')
self.handled.clear()
self.sl_hdlr.append_nul = False
logger.error("
sp
\
xe4m
")
self.handled.wait()
self.assertEqual(self.log_output, b'<11>
\
xef
\
xbb
\
xbf
sp
\
xc3
\
xa4
m')
@unittest.skipUnless(threading, 'Threading required for this test.')
...
...
Misc/NEWS
View file @
8dd8d582
...
...
@@ -187,6 +187,9 @@ Core and Builtins
Library
-------
- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
a new '
append_nul
' attribute on the handler.
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
instead of os.stat.
...
...
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