In some cases, the code to show the location of a logging statement failed with an exception, resulting in no logging. Catch this, so something is logged.

- Legacy-Id: 1716
This commit is contained in:
Henrik Levkowetz 2009-10-08 13:26:28 +00:00
parent 58e716c2cd
commit 632a588e72

View file

@ -21,13 +21,16 @@ def getcaller():
return (pmodule, pclass, pfunction, pfile, pline)
def log(msg):
mod, cls, func, file, line = getcaller()
file = os.path.abspath(file)
file = file.replace(settings.BASE_DIR, "")
if func == "<module>":
where = ""
else:
where = " in " + func + "()"
try:
mod, cls, func, file, line = getcaller()
file = os.path.abspath(file)
file = file.replace(settings.BASE_DIR, "")
if func == "<module>":
where = ""
else:
where = " in " + func + "()"
except IndexError:
file, line, where = "/<UNKNOWN>", 0, ""
syslog.syslog("ietf%s(%d)%s: %s" % (file, line, where, msg))
log("IETFdb v%s started" % ietf.__version__)