comparison MoinMoin/config/multiconfig.py @ 3157:b8cb12fa571b

logging: using more logging.exception
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 01 Mar 2008 17:10:35 +0100
parents 6749e003d7e2
children 2a3a6cb34e45
comparison
equal deleted inserted replaced
3156:1508feb6dbbf 3157:b8cb12fa571b
45 module = __import__(name, globals(), {}) 45 module = __import__(name, globals(), {})
46 mtime = os.path.getmtime(module.__file__) 46 mtime = os.path.getmtime(module.__file__)
47 except ImportError: 47 except ImportError:
48 raise 48 raise
49 except IndentationError, err: 49 except IndentationError, err:
50 logging.error(str(err)) 50 logging.exception('Your source code / config file is not correctly indented!')
51 msg = '''IndentationError: %(err)s 51 msg = '''IndentationError: %(err)s
52 52
53 The configuration files are python modules. Therefore, whitespace is 53 The configuration files are python modules. Therefore, whitespace is
54 important. Make sure that you use only spaces, no tabs are allowed here! 54 important. Make sure that you use only spaces, no tabs are allowed here!
55 You have to use four spaces at the beginning of the line mostly. 55 You have to use four spaces at the beginning of the line mostly.
56 ''' % { 56 ''' % {
57 'err': err, 57 'err': err,
58 } 58 }
59 raise error.ConfigurationError(msg) 59 raise error.ConfigurationError(msg)
60 except Exception, err: 60 except Exception, err:
61 logging.error(str(err)) 61 logging.exception('An exception happened.')
62 msg = '%s: %s' % (err.__class__.__name__, str(err)) 62 msg = '%s: %s' % (err.__class__.__name__, str(err))
63 raise error.ConfigurationError(msg) 63 raise error.ConfigurationError(msg)
64 return module, mtime 64 return module, mtime
65 65
66 66
116 configClass = getattr(module, 'Config') 116 configClass = getattr(module, 'Config')
117 cfg = configClass(name) 117 cfg = configClass(name)
118 cfg.cfg_mtime = max(mtime, _farmconfig_mtime) 118 cfg.cfg_mtime = max(mtime, _farmconfig_mtime)
119 logging.info("using wiki config: %s" % os.path.abspath(module.__file__)) 119 logging.info("using wiki config: %s" % os.path.abspath(module.__file__))
120 except ImportError, err: 120 except ImportError, err:
121 logging.error(str(err)) 121 logging.exception('Could not import.')
122 msg = '''ImportError: %(err)s 122 msg = '''ImportError: %(err)s
123 123
124 Check that the file is in the same directory as the server script. If 124 Check that the file is in the same directory as the server script. If
125 it is not, you must add the path of the directory where the file is 125 it is not, you must add the path of the directory where the file is
126 located to the python path in the server script. See the comments at 126 located to the python path in the server script. See the comments at
132 ''' % { 132 ''' % {
133 'err': err, 133 'err': err,
134 } 134 }
135 raise error.ConfigurationError(msg) 135 raise error.ConfigurationError(msg)
136 except AttributeError, err: 136 except AttributeError, err:
137 logging.error(str(err)) 137 logging.exception('An exception occured.')
138 msg = '''AttributeError: %(err)s 138 msg = '''AttributeError: %(err)s
139 139
140 Could not find required "Config" class in "%(name)s.py". 140 Could not find required "Config" class in "%(name)s.py".
141 141
142 This might happen if you are trying to use a pre 1.3 configuration file, or 142 This might happen if you are trying to use a pre 1.3 configuration file, or