Replace print with logging
This commit is contained in:
parent
cef02d0700
commit
f923cd2c50
20
README.md
20
README.md
|
@ -115,3 +115,23 @@ coverage report # for command-line report
|
||||||
coverage html # for HTML report
|
coverage html # for HTML report
|
||||||
open htmlcov/index.html
|
open htmlcov/index.html
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Logging
|
||||||
|
-------
|
||||||
|
|
||||||
|
To enable from your own code:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import logging
|
||||||
|
import pylast
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
network = pylast.LastFMNetwork(...)
|
||||||
|
```
|
||||||
|
|
||||||
|
To enable from pytest:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pytest -k test_album_search_images --log-cli-level debug
|
||||||
|
```
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
from xml.dom import minidom, Node
|
from xml.dom import minidom, Node
|
||||||
import collections
|
import collections
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import logging
|
||||||
import shelve
|
import shelve
|
||||||
import six
|
import six
|
||||||
import ssl
|
import ssl
|
||||||
|
@ -110,6 +111,9 @@ SCROBBLE_MODE_SKIPPED = "S"
|
||||||
# Python >3.4 and >2.7.9 has sane defaults
|
# Python >3.4 and >2.7.9 has sane defaults
|
||||||
SSL_CONTEXT = ssl.create_default_context()
|
SSL_CONTEXT = ssl.create_default_context()
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||||
|
|
||||||
|
|
||||||
class _Network(object):
|
class _Network(object):
|
||||||
"""
|
"""
|
||||||
|
@ -732,7 +736,7 @@ class _Request(object):
|
||||||
"""Representing an abstract web service operation."""
|
"""Representing an abstract web service operation."""
|
||||||
|
|
||||||
def __init__(self, network, method_name, params=None):
|
def __init__(self, network, method_name, params=None):
|
||||||
print(method_name)
|
logger.debug(method_name)
|
||||||
|
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
|
|
|
@ -140,7 +140,6 @@ class TestPyLastTrack(PyLastTestCase):
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
album = track.get_album()
|
album = track.get_album()
|
||||||
print(album)
|
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(str(album), "Nirvana - Nevermind")
|
self.assertEqual(str(album), "Nirvana - Nevermind")
|
||||||
|
|
Loading…
Reference in a new issue