Commit e820dbef authored by Philipp Hörist's avatar Philipp Hörist

Add logging for method iq_request_task calls

parent bab56bc1
......@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
import inspect
from urllib.parse import urlparse
from urllib.parse import unquote
......@@ -61,3 +62,16 @@ def parse_xmpp_uri(uri):
dict_[key] = unquote(value)
return (url.path, action, dict_)
def make_func_arguments_string(func, self, args, kwargs):
signature = inspect.signature(func)
bound_arguments = signature.bind(self, *args, **kwargs)
bound_arguments.apply_defaults()
arg_string = ''
for name, arg in bound_arguments.arguments.items():
if name == 'self':
continue
arg_string += f'{name}={arg}, '
arg_string = arg_string[:-2]
return f'{func.__name__}({arg_string})'
......@@ -27,6 +27,7 @@ from nbxmpp.errors import is_error
from nbxmpp.errors import CancelledError
from nbxmpp.errors import TimeoutStanzaError
from nbxmpp.simplexml import Node
from nbxmpp.modules.util import make_func_arguments_string
log = logging.getLogger('nbxmpp.task')
......@@ -78,6 +79,8 @@ def _setup_task(task, client, callback, user_data):
def iq_request_task(func):
@wraps(func)
def func_wrapper(self, *args, timeout=None, callback=None, user_data=None, **kwargs):
if self._log.isEnabledFor(logging.INFO):
self._log.info(make_func_arguments_string(func, self, args, kwargs))
task = IqRequestTask(func(self, *args, **kwargs),
self._log,
self._client)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment