summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2004-09-24 11:45:13 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2004-09-24 11:45:13 (GMT)
commit02dd994adf7de5ea6521b0f405b80d78c7081fee (patch)
tree5f8bef69270d5c9646f7e768cfe64fe28fa1a51f /Lib
parent1cc37380b241956d2544ab5fd53de272603a58b9 (diff)
downloadcpython-02dd994adf7de5ea6521b0f405b80d78c7081fee.zip
cpython-02dd994adf7de5ea6521b0f405b80d78c7081fee.tar.gz
cpython-02dd994adf7de5ea6521b0f405b80d78c7081fee.tar.bz2
Added exception handling during handler initialization in fileConfig()
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/config.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index c9ffab0..92f2af0 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -98,31 +98,34 @@ def fileConfig(fname, defaults=None):
handlers = {}
fixups = [] #for inter-handler references
for hand in hlist:
- sectname = "handler_%s" % hand
- klass = cp.get(sectname, "class")
- opts = cp.options(sectname)
- if "formatter" in opts:
- fmt = cp.get(sectname, "formatter")
- else:
- fmt = ""
- klass = eval(klass, vars(logging))
- args = cp.get(sectname, "args")
- args = eval(args, vars(logging))
- h = apply(klass, args)
- if "level" in opts:
- level = cp.get(sectname, "level")
- h.setLevel(logging._levelNames[level])
- if len(fmt):
- h.setFormatter(formatters[fmt])
- #temporary hack for FileHandler and MemoryHandler.
- if klass == logging.handlers.MemoryHandler:
- if "target" in opts:
- target = cp.get(sectname,"target")
+ try:
+ sectname = "handler_%s" % hand
+ klass = cp.get(sectname, "class")
+ opts = cp.options(sectname)
+ if "formatter" in opts:
+ fmt = cp.get(sectname, "formatter")
else:
- target = ""
- if len(target): #the target handler may not be loaded yet, so keep for later...
- fixups.append((h, target))
- handlers[hand] = h
+ fmt = ""
+ klass = eval(klass, vars(logging))
+ args = cp.get(sectname, "args")
+ args = eval(args, vars(logging))
+ h = apply(klass, args)
+ if "level" in opts:
+ level = cp.get(sectname, "level")
+ h.setLevel(logging._levelNames[level])
+ if len(fmt):
+ h.setFormatter(formatters[fmt])
+ #temporary hack for FileHandler and MemoryHandler.
+ if klass == logging.handlers.MemoryHandler:
+ if "target" in opts:
+ target = cp.get(sectname,"target")
+ else:
+ target = ""
+ if len(target): #the target handler may not be loaded yet, so keep for later...
+ fixups.append((h, target))
+ handlers[hand] = h
+ except: #if an error occurs when instantiating a handler, too bad
+ pass #this could happen e.g. because of lack of privileges
#now all handlers are loaded, fixup inter-handler references...
for fixup in fixups:
h = fixup[0]