diff --git a/splunklib/binding.py b/splunklib/binding.py index 229561cd2..2b5078c56 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -55,13 +55,15 @@ DEFAULT_PORT = "8089" DEFAULT_SCHEME = "https" +log = logging.getLogger(__name__) + def _log_duration(f): @wraps(f) def new_f(*args, **kwargs): start_time = datetime.now() val = f(*args, **kwargs) end_time = datetime.now() - logging.debug("Operation took %s", end_time-start_time) + log.debug("Operation took %s", end_time-start_time) return val return new_f @@ -523,7 +525,7 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query): """ path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing) - logging.debug("DELETE request to %s (body: %s)", path, repr(query)) + log.debug("DELETE request to %s (body: %s)", path, repr(query)) response = self.http.delete(path, self._auth_headers, **query) return response @@ -581,7 +583,7 @@ def get(self, path_segment, owner=None, app=None, sharing=None, **query): """ path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing) - logging.debug("GET request to %s (body: %s)", path, repr(query)) + log.debug("GET request to %s (body: %s)", path, repr(query)) response = self.http.get(path, self._auth_headers, **query) return response @@ -653,7 +655,7 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, * headers = [] path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing) - logging.debug("POST request to %s (body: %s)", path, repr(query)) + log.debug("POST request to %s (body: %s)", path, repr(query)) all_headers = headers + self._auth_headers response = self.http.post(path, all_headers, **query) return response @@ -721,7 +723,7 @@ def request(self, path_segment, method="GET", headers=None, body="", + self._abspath(path_segment, owner=owner, app=app, sharing=sharing) all_headers = headers + self._auth_headers - logging.debug("%s request to %s (headers: %s, body: %s)", + log.debug("%s request to %s (headers: %s, body: %s)", method, path, str(all_headers), repr(body)) response = self.http.request(path, {'method': method, diff --git a/splunklib/client.py b/splunklib/client.py index add98b0d6..0c8cd5099 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -110,6 +110,8 @@ MATCH_ENTRY_CONTENT = "%s/%s/*" % (XNAME_ENTRY, XNAME_CONTENT) +log = logging.getLogger(__name__) + class IllegalOperationException(Exception): """Thrown when an operation is not possible on the Splunk instance that a @@ -1387,7 +1389,7 @@ def iter(self, offset=0, count=None, pagesize=None, **kwargs): if pagesize is None or N < pagesize: break offset += N - logging.debug("pagesize=%d, fetched=%d, offset=%d, N=%d, kwargs=%s", pagesize, fetched, offset, N, kwargs) + log.debug("pagesize=%d, fetched=%d, offset=%d, N=%d, kwargs=%s", pagesize, fetched, offset, N, kwargs) # kwargs: count, offset, search, sort_dir, sort_key, sort_mode def list(self, count=None, **kwargs): @@ -2455,9 +2457,9 @@ def list(self, *kinds, **kwargs): kinds = self.kinds if len(kinds) == 1: kind = kinds[0] - logging.debug("Inputs.list taking short circuit branch for single kind.") + log.debug("Inputs.list taking short circuit branch for single kind.") path = self.kindpath(kind) - logging.debug("Path for inputs: %s", path) + log.debug("Path for inputs: %s", path) try: path = UrlEncoded(path, skip_encode=True) response = self.get(path, **kwargs)