Skip to content

Commit

Permalink
Brought excluded code into the scope of a try block in SysLogHandler.…
Browse files Browse the repository at this point in the history
…emit().
  • Loading branch information
vsajip committed Nov 1, 2014
1 parent 8083cd6 commit c33a0cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,21 +879,21 @@ def emit(self, record):
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)
if self.ident:
msg = self.ident + msg
if self.append_nul:
msg += '\000'

# We need to convert record level to lowercase, maybe this will
# change in the future.
prio = '<%d>' % self.encodePriority(self.facility,
self.mapPriority(record.levelname))
prio = prio.encode('utf-8')
# Message is a string. Convert to bytes as required by RFC 5424
msg = msg.encode('utf-8')
msg = prio + msg
try:
msg = self.format(record)
if self.ident:
msg = self.ident + msg
if self.append_nul:
msg += '\000'

# We need to convert record level to lowercase, maybe this will
# change in the future.
prio = '<%d>' % self.encodePriority(self.facility,
self.mapPriority(record.levelname))
prio = prio.encode('utf-8')
# Message is a string. Convert to bytes as required by RFC 5424
msg = msg.encode('utf-8')
msg = prio + msg
if self.unixsocket:
try:
self.socket.send(msg)
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Core and Builtins
Library
-------

- Issue #22776: Brought excluded code into the scope of a try block in
SysLogHandler.emit().

- Issue #22665: Add missing get_terminal_size and SameFileError to
shutil.__all__.

Expand Down

0 comments on commit c33a0cc

Please sign in to comment.