From dd8836e59b8806d5a78818a9bcad0844d4d0c84c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 3 Mar 2022 13:15:26 +0200 Subject: [PATCH] Logging: log method names at INFO level, also log API return data at DEBUG level --- README.md | 8 ++++++-- src/pylast/__init__.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1232eb1..1a2a667 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,8 @@ To enable from your own code: import logging import pylast -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.INFO) + network = pylast.LastFMNetwork(...) ``` @@ -152,5 +153,8 @@ network = pylast.LastFMNetwork(...) To enable from pytest: ```sh -pytest --log-cli-level debug -k test_album_search_images +pytest --log-cli-level info -k test_album_search_images ``` + +To also see data returned from the API, use `level=logging.DEBUG` or +`--log-cli-level debug` instead. diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index cfbe52f..3065e7d 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -822,7 +822,7 @@ class _Request: """Representing an abstract web service operation.""" def __init__(self, network, method_name, params=None): - logger.debug(method_name) + logger.info(method_name) if params is None: params = {} @@ -962,7 +962,7 @@ class _Request: raise MalformedResponseError(self.network, e) from e e = doc.getElementsByTagName("lfm")[0] - # logger.debug(doc.toprettyxml()) + logger.debug(doc.toprettyxml()) if e.getAttribute("status") != "ok": e = doc.getElementsByTagName("error")[0]