Skip to content

Commit 0a7df63

Browse files
authored
Logging: reduce log verbosity (#9348)
1 parent c6afdb7 commit 0a7df63

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

readthedocs/builds/tasks.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,22 @@ def archive_builds_task(self, days=14, limit=200, delete=False):
210210
commands = BuildCommandSerializer(build.commands, many=True).data
211211
if commands:
212212
for cmd in commands:
213-
if len(cmd['output']) > MAX_BUILD_COMMAND_SIZE:
214-
cmd['output'] = cmd['output'][-MAX_BUILD_COMMAND_SIZE:]
215-
cmd['output'] = "... (truncated) ...\n\nCommand output too long. Truncated to last 1MB.\n\n" + cmd['output'] # noqa
216-
log.warning('Truncating build command for build.', build_id=build.id)
217-
output = BytesIO(json.dumps(commands).encode('utf8'))
218-
filename = '{date}/{id}.json'.format(date=str(build.date.date()), id=build.id)
213+
if len(cmd["output"]) > MAX_BUILD_COMMAND_SIZE:
214+
cmd["output"] = cmd["output"][-MAX_BUILD_COMMAND_SIZE:]
215+
cmd["output"] = (
216+
"\n\n"
217+
"... (truncated) ..."
218+
"\n\n"
219+
"Command output too long. Truncated to last 1MB."
220+
"\n\n" + cmd["output"]
221+
) # noqa
222+
log.debug(
223+
"Truncating build command for build.", build_id=build.id
224+
)
225+
output = BytesIO(json.dumps(commands).encode("utf8"))
226+
filename = "{date}/{id}.json".format(
227+
date=str(build.date.date()), id=build.id
228+
)
219229
try:
220230
build_commands_storage.save(name=filename, content=output)
221231
if delete:

readthedocs/proxito/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def process_request(self, request): # noqa
313313
try:
314314
project = Project.objects.get(slug=request.host_project_slug)
315315
except Project.DoesNotExist:
316-
log.warning('No host_project_slug set on project')
316+
log.debug("No host_project_slug set on project")
317317
return None
318318

319319
# This is hacky because Django wants a module for the URLConf,

readthedocs/proxito/views/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
import structlog
32

3+
import structlog
44
from django.http import HttpResponse
55
from django.shortcuts import get_object_or_404, render
66

@@ -60,8 +60,8 @@ def _get_project_data_from_request(
6060
if lang_slug and version_slug:
6161
filename = os.path.join(lang_slug, version_slug, filename)
6262
log.warning(
63-
'URL looks like versioned on a single version project.'
64-
'Changing filename to match.',
63+
"URL looks like versioned on a single version project. "
64+
"Changing filename to match.",
6565
filename=filename,
6666
)
6767
lang_slug = version_slug = None

0 commit comments

Comments
 (0)