Skip to content

Commit

Permalink
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/setup.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

setup(
name="balrogclient",
version="1.1.0",
version="1.1.1",
description="Balrog Admin API Client",
author="Mozilla Release Engineers",
author_email="release+python@mozilla.com",
6 changes: 4 additions & 2 deletions client/src/balrogclient/api.py
Original file line number Diff line number Diff line change
@@ -9,15 +9,17 @@
import requests
import requests.auth

MAX_LOG_LINE_LENGTH = 10000
# Refresh the tokens 5 minutes before they expire
REFRESH_THRESHOLD = 5 * 60
_token_cache = {}


def _json_log_data(data):
log = json.dumps(data)
if len(log) > 100:
log = log[:80] + "<...{} characters elided ...>".format(len(log) - 80)
if len(log) > MAX_LOG_LINE_LENGTH:
slice_length = MAX_LOG_LINE_LENGTH - 20
log = log[:slice_length] + "<...{} characters elided ...>".format(len(log) - slice_length)
return log


4 changes: 2 additions & 2 deletions client/tests/test_balrog_api.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def test_log_lines_truncated(caplog):
caplog.set_level(logging.DEBUG)

api = API(AUTH0_SECRETS, session=session)
api.do_request("https://api/", {"data": "a" * 100}, "GET")
api.do_request("https://api/", {"data": "a" * 11000}, "GET")

logs = [message.split(": ", 1)[1] for message in caplog.messages if message.startswith("Data sent: ")]
assert logs == ['{"data": "' + "a" * 70 + "<...32 characters elided ...>"]
assert logs == ['{"data": "' + "a" * 9970 + "<...1032 characters elided ...>"]

0 comments on commit 54b01d2

Please sign in to comment.