diff --git a/owncloud/owncloud.py b/owncloud/owncloud.py index 0ab873c..8b57d61 100644 --- a/owncloud/owncloud.py +++ b/owncloud/owncloud.py @@ -15,9 +15,13 @@ import os import math import six +import logging from six.moves.urllib import parse +LOGGER = logging.getLogger(__name__) + + class ResponseError(Exception): def __init__(self, res, errorType): if type(res) is int: @@ -322,7 +326,7 @@ def __init__(self, url, **kwargs): :param verify_certs: True (default) to verify SSL certificates, False otherwise :param dav_endpoint_version: None (default) to force using a specific endpoint version instead of relying on capabilities - :param debug: set to True to print debugging messages to stdout, defaults to False + :param debug: set to True to log debugging messages with python logging, defaults to False """ if not url.endswith('/'): url += '/' @@ -1265,7 +1269,7 @@ def share_file_with_user(self, path, user, **kwargs): ) if self._debug: - print('OCS share_file request for file %s with permissions %i ' + LOGGER.debug('OCS share_file request for file %s with permissions %i ' 'returned: %i' % (path, perms, res.status_code)) if res.status_code == 200: tree = ET.fromstring(res.content) @@ -1713,7 +1717,7 @@ def _make_ocs_request(self, method, service, action, **kwargs): attributes['headers']['OCS-APIREQUEST'] = 'true' if self._debug: - print('OCS request: %s %s %s' % (method, self.url + path, + LOGGER.debug('OCS request: %s %s %s' % (method, self.url + path, attributes)) res = self._session.request(method, self.url + path, **attributes) @@ -1730,9 +1734,9 @@ def _make_dav_request(self, method, path, **kwargs): if it didn't """ if self._debug: - print('DAV request: %s %s' % (method, path)) + LOGGER.debug('DAV request: %s %s' % (method, path)) if kwargs.get('headers'): - print('Headers: ', kwargs.get('headers')) + LOGGER.debug('Headers: ', kwargs.get('headers')) path = self._normalize_path(path) res = self._session.request( @@ -1741,7 +1745,7 @@ def _make_dav_request(self, method, path, **kwargs): **kwargs ) if self._debug: - print('DAV status: %i' % res.status_code) + LOGGER.debug('DAV status: %i' % res.status_code) if res.status_code in [200, 207]: return self._parse_dav_response(res) if res.status_code in [204, 201]: