Wrap inspect.stack in if __debug__
This commit is contained in:
parent
fd26b5f066
commit
22c1d79eae
@ -157,15 +157,16 @@ def wrapper(method):
|
|||||||
This 'wrapped' method logs the original function that was called, and
|
This 'wrapped' method logs the original function that was called, and
|
||||||
where it was called from.
|
where it was called from.
|
||||||
"""
|
"""
|
||||||
class_name = args[0].__class__.__name__
|
if __debug__:
|
||||||
func_name = method.__name__
|
class_name = args[0].__class__.__name__
|
||||||
frame = inspect.currentframe()
|
func_name = method.__name__
|
||||||
c_frame = frame.f_back
|
frame = inspect.currentframe()
|
||||||
c_code = c_frame.f_code
|
c_frame = frame.f_back
|
||||||
LOG.debug('calling %s.%s()... from file %s, line %s in %s',
|
c_code = c_frame.f_code
|
||||||
class_name, func_name, c_code.co_filename, c_frame.f_lineno,
|
LOG.debug('calling %s.%s()... from file %s, line %s in %s',
|
||||||
c_code.co_name)
|
class_name, func_name, c_code.co_filename,
|
||||||
return method(*args, **keywargs)
|
c_frame.f_lineno, c_code.co_name)
|
||||||
|
return method(*args, **keywargs)
|
||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,15 +71,15 @@ def make_database(plugin_id):
|
|||||||
if mod:
|
if mod:
|
||||||
database = getattr(mod, pdata.databaseclass)
|
database = getattr(mod, pdata.databaseclass)
|
||||||
db = database()
|
db = database()
|
||||||
import inspect
|
if __debug__:
|
||||||
frame = inspect.currentframe()
|
import inspect
|
||||||
c_frame = frame.f_back
|
frame = inspect.currentframe()
|
||||||
c_code = c_frame.f_code
|
c_frame = frame.f_back
|
||||||
_LOG.debug("Database class instance created Class:%s instance:%s. "
|
c_code = c_frame.f_code
|
||||||
"Called from File %s, line %s, in %s",
|
_LOG.debug("Database class instance created Class:%s instance:%s. "
|
||||||
db.__class__.__name__, hex(id(db)), c_code.co_filename,
|
"Called from File %s, line %s, in %s",
|
||||||
c_frame.f_lineno, c_code.co_name)
|
db.__class__.__name__, hex(id(db)), c_code.co_filename,
|
||||||
|
c_frame.f_lineno, c_code.co_name)
|
||||||
return db
|
return db
|
||||||
else:
|
else:
|
||||||
raise Exception("can't load database backend: '%s'" % plugin_id)
|
raise Exception("can't load database backend: '%s'" % plugin_id)
|
||||||
|
@ -85,14 +85,15 @@ class DbState(Callback):
|
|||||||
This replaces tests on DbState.open, DbState.db, DbState.db.is_open()
|
This replaces tests on DbState.open, DbState.db, DbState.db.is_open()
|
||||||
and DbState.db.db_is_open all of which are deprecated.
|
and DbState.db.db_is_open all of which are deprecated.
|
||||||
"""
|
"""
|
||||||
class_name = self.__class__.__name__
|
if __debug__:
|
||||||
func_name = "is_open"
|
class_name = self.__class__.__name__
|
||||||
frame = inspect.currentframe()
|
func_name = "is_open"
|
||||||
c_frame = frame.f_back
|
frame = inspect.currentframe()
|
||||||
c_code = c_frame.f_code
|
c_frame = frame.f_back
|
||||||
_LOG.debug('calling %s.%s()... from file %s, line %s in %s',
|
c_code = c_frame.f_code
|
||||||
class_name, func_name, c_code.co_filename, c_frame.f_lineno,
|
_LOG.debug('calling %s.%s()... from file %s, line %s in %s',
|
||||||
c_code.co_name)
|
class_name, func_name, c_code.co_filename,
|
||||||
|
c_frame.f_lineno, c_code.co_name)
|
||||||
return (self.db is not None) and self.db.is_open()
|
return (self.db is not None) and self.db.is_open()
|
||||||
|
|
||||||
def change_database(self, database):
|
def change_database(self, database):
|
||||||
|
Loading…
Reference in New Issue
Block a user