Skip inspect.stack also when debug logging is disabled
This commit is contained in:
parent
22c1d79eae
commit
eb6ee86d09
@ -157,7 +157,7 @@ def wrapper(method):
|
||||
This 'wrapped' method logs the original function that was called, and
|
||||
where it was called from.
|
||||
"""
|
||||
if __debug__:
|
||||
if __debug__ and LOG.isEnabledFor(logging.DEBUG):
|
||||
class_name = args[0].__class__.__name__
|
||||
func_name = method.__name__
|
||||
frame = inspect.currentframe()
|
||||
|
@ -77,7 +77,7 @@ class DbTxn(defaultdict):
|
||||
self.db.transaction_abort(self)
|
||||
|
||||
elapsed_time = time.time() - self.start_time
|
||||
if __debug__:
|
||||
if __debug__ and _LOG.isEnabledFor(logging.DEBUG):
|
||||
frame = inspect.currentframe()
|
||||
c_frame = frame.f_back
|
||||
c_code = c_frame.f_code
|
||||
@ -122,7 +122,7 @@ class DbTxn(defaultdict):
|
||||
"""
|
||||
|
||||
# Conditional on __debug__ because all that frame stuff may be slow
|
||||
if __debug__:
|
||||
if __debug__ and _LOG.isEnabledFor(logging.DEBUG):
|
||||
caller_frame = inspect.stack()[1]
|
||||
# If the call comes from gramps.gen.db.generic.DbGenericTxn.__init__
|
||||
# then it is just a dummy redirect, so we need to go back another
|
||||
|
@ -71,7 +71,7 @@ def make_database(plugin_id):
|
||||
if mod:
|
||||
database = getattr(mod, pdata.databaseclass)
|
||||
db = database()
|
||||
if __debug__:
|
||||
if __debug__ and _LOG.isEnabledFor(logging.DEBUG):
|
||||
import inspect
|
||||
frame = inspect.currentframe()
|
||||
c_frame = frame.f_back
|
||||
|
@ -85,7 +85,7 @@ class DbState(Callback):
|
||||
This replaces tests on DbState.open, DbState.db, DbState.db.is_open()
|
||||
and DbState.db.db_is_open all of which are deprecated.
|
||||
"""
|
||||
if __debug__:
|
||||
if __debug__ and _LOG.isEnabledFor(logging.DEBUG):
|
||||
class_name = self.__class__.__name__
|
||||
func_name = "is_open"
|
||||
frame = inspect.currentframe()
|
||||
|
Loading…
Reference in New Issue
Block a user