Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down