Skip to content

Commit

Permalink
feat(send_kcidb.py): Remove log_excerpt from console logs
Browse files Browse the repository at this point in the history
log_excerpt is too large and fills up truncated docker and k8s
logs. Better to remove it from log output.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Oct 9, 2024
1 parent 4fac03e commit 73c7b94
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/send_kcidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ def _remove_none_fields(self, data):
return [self._remove_none_fields(item) for item in data]
return data

def remove_log_excerpts(self, data):
if isinstance(data, dict):
# Remove 'log_excerpt' if it exists in this dictionary
data.pop('log_excerpt', None)

# Recursively process all values in the dictionary
for key, value in data.items():
data[key] = self.remove_log_excerpts(value)
elif isinstance(data, list):
# Recursively process all items in the list
return [self.remove_log_excerpts(item) for item in data]

return data

def _print_debug(self, data):
'''
Remove log_excerpt field, as it is filling up the logs
'''
log_data = data.copy()
log_data = self.remove_log_excerpts(log_data)
self.log.debug(f"Sending revision: {log_data}")

def _send_revision(self, client, revision):
revision = self._remove_none_fields(revision)
if any(value for key, value in revision.items() if key != 'version'):
self.log.debug(f"DEBUG: sending revision: {revision}")
# remove log_excerpt field, as it is filling up the logs
log_data = revision.copy()
self._print_debug(log_data)
if kcidb.io.SCHEMA.is_valid(revision):
client.submit(revision)
else:
Expand Down

0 comments on commit 73c7b94

Please sign in to comment.