Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code.
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index 3017ae9..99403d2 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -19,15 +19,12 @@
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
by Apache's log4j system.
-Should work under Python versions >= 1.5.2, except that source line
-information is not available unless 'sys._getframe()' is.
-
-Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
-import sys, logging, logging.handlers, string, socket, struct, os, traceback, types
+import sys, logging, logging.handlers, socket, struct, os, traceback
try:
import thread
@@ -52,7 +49,7 @@
# _listener holds the server object doing the listening
_listener = None
-def fileConfig(fname, defaults=None, disable_existing_loggers=1):
+def fileConfig(fname, defaults=None, disable_existing_loggers=True):
"""
Read the logging configuration from a ConfigParser-format file.
@@ -89,7 +86,7 @@
def _resolve(name):
"""Resolve a dotted name to a global object."""
- name = string.split(name, '.')
+ name = name.split('.')
used = name.pop(0)
found = __import__(used)
for n in name:
@@ -102,14 +99,14 @@
return found
def _strip_spaces(alist):
- return map(lambda x: string.strip(x), alist)
+ return map(lambda x: x.strip(), alist)
def _create_formatters(cp):
"""Create and return formatters"""
flist = cp.get("formatters", "keys")
if not len(flist):
return {}
- flist = string.split(flist, ",")
+ flist = flist.split(",")
flist = _strip_spaces(flist)
formatters = {}
for form in flist:
@@ -138,7 +135,7 @@
hlist = cp.get("handlers", "keys")
if not len(hlist):
return {}
- hlist = string.split(hlist, ",")
+ hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
handlers = {}
fixups = [] #for inter-handler references
@@ -181,8 +178,8 @@
# configure the root first
llist = cp.get("loggers", "keys")
- llist = string.split(llist, ",")
- llist = map(lambda x: string.strip(x), llist)
+ llist = llist.split(",")
+ llist = list(map(lambda x: x.strip(), llist))
llist.remove("root")
sectname = "logger_root"
root = logging.root
@@ -195,7 +192,7 @@
root.removeHandler(h)
hlist = cp.get(sectname, "handlers")
if len(hlist):
- hlist = string.split(hlist, ",")
+ hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
for hand in hlist:
log.addHandler(handlers[hand])
@@ -209,7 +206,7 @@
#what's left in existing is the set of loggers
#which were in the previous configuration but
#which are not in the new configuration.
- existing = root.manager.loggerDict.keys()
+ existing = list(root.manager.loggerDict.keys())
#The list needs to be sorted so that we can
#avoid disabling child loggers of explicitly
#named loggers. With a sorted list it is easier
@@ -247,7 +244,7 @@
logger.disabled = 0
hlist = cp.get(sectname, "handlers")
if len(hlist):
- hlist = string.split(hlist, ",")
+ hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
for hand in hlist:
logger.addHandler(handlers[hand])
@@ -278,7 +275,7 @@
stopListening().
"""
if not thread:
- raise NotImplementedError, "listen() needs threading to work"
+ raise NotImplementedError("listen() needs threading to work")
class ConfigStreamHandler(StreamRequestHandler):
"""
@@ -321,7 +318,7 @@
traceback.print_exc()
os.remove(file)
except socket.error, e:
- if type(e.args) != types.TupleType:
+ if not isinstance(e.args, tuple):
raise
else:
errcode = e.args[0]