faster than inspect

This commit is contained in:
Will McGugan
2022-10-12 14:34:46 +01:00
parent bc86cdd303
commit e7e6b56ea3
2 changed files with 7 additions and 2 deletions

View File

@@ -54,7 +54,10 @@ class Logger:
raise LoggerError("Unable to log without an active app.") from None raise LoggerError("Unable to log without an active app.") from None
if not app.devtools.is_connected: if not app.devtools.is_connected:
return return
caller = inspect.stack(0)[1]
previous_frame = inspect.currentframe().f_back
caller = inspect.getframeinfo(previous_frame)
_log = self._log or app._log _log = self._log or app._log
try: try:
_log( _log(

View File

@@ -39,7 +39,9 @@ class StdoutRedirector:
if not self.devtools.is_connected: if not self.devtools.is_connected:
return return
caller = inspect.stack(0)[1] previous_frame = inspect.currentframe().f_back
caller = inspect.getframeinfo(previous_frame)
self._buffer.append(DevtoolsLog(string, caller=caller)) self._buffer.append(DevtoolsLog(string, caller=caller))
# By default, `print` adds a "\n" suffix which results in a buffer # By default, `print` adds a "\n" suffix which results in a buffer