mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] Update MoulinetteLogger with 3.5 logger
This commit is contained in:
parent
ba38fa2743
commit
5ffe6a4b8c
1 changed files with 13 additions and 3 deletions
|
@ -85,19 +85,29 @@ class MoulinetteLogger(Logger):
|
||||||
if self.isEnabledFor(SUCCESS):
|
if self.isEnabledFor(SUCCESS):
|
||||||
self._log(SUCCESS, msg, args, **kwargs)
|
self._log(SUCCESS, msg, args, **kwargs)
|
||||||
|
|
||||||
def findCaller(self):
|
def findCaller(self, stack_info=False):
|
||||||
"""Override findCaller method to consider this source file."""
|
"""Override findCaller method to consider this source file."""
|
||||||
f = logging.currentframe()
|
f = logging.currentframe()
|
||||||
if f is not None:
|
if f is not None:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
rv = "(unknown file)", 0, "(unknown function)"
|
rv = "(unknown file)", 0, "(unknown function)", None
|
||||||
while hasattr(f, "f_code"):
|
while hasattr(f, "f_code"):
|
||||||
co = f.f_code
|
co = f.f_code
|
||||||
filename = os.path.normcase(co.co_filename)
|
filename = os.path.normcase(co.co_filename)
|
||||||
if filename == logging._srcfile or filename == __file__:
|
if filename == logging._srcfile or filename == __file__:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
continue
|
continue
|
||||||
rv = (co.co_filename, f.f_lineno, co.co_name)
|
|
||||||
|
sinfo = None
|
||||||
|
if stack_info:
|
||||||
|
sio = io.StringIO()
|
||||||
|
sio.write('Stack (most recent call last):\n')
|
||||||
|
traceback.print_stack(f, file=sio)
|
||||||
|
sinfo = sio.getvalue()
|
||||||
|
if sinfo[-1] == '\n':
|
||||||
|
sinfo = sinfo[:-1]
|
||||||
|
sio.close()
|
||||||
|
rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
|
||||||
break
|
break
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue