Skip to content

Commit

Permalink
Merge branch 'master' into TDRD-319-keycloak-upgrade-v25
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJKing authored Dec 9, 2024
2 parents fa49ebe + 97f79ad commit b47c95d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .github/scripts/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@
log_group_name = sys.argv[3]
log_stream_name = sys.argv[2]


def split_message(s, length):
for i in range(0, len(s), length):
yield s[i:i + length]


log_event = []
with open(sys.argv[1]) as file:
message = file.read()
if len(message.encode("utf-8")) > 262144:
message_list = message.split("\n")
mid_point = len(message_list) // 2
first_half = "\n".join(message_list[0: mid_point])
second_half = "\n".join(message_list[mid_point:])
log_event = [{'timestamp': timestamp, 'message': first_half}, {'timestamp': timestamp, 'message': second_half}]
main_message = message.split("::debug::stdout:")[0]
if len(main_message.encode("utf-8")) > 262144:
for chunk in split_message(main_message, 262100):
log_event.append({'timestamp': timestamp, 'message': chunk})
else:
log_event = [{'timestamp': timestamp, 'message': message}]
log_event = [{'timestamp': timestamp, 'message': main_message}]

client.create_log_stream(logGroupName=log_group_name, logStreamName=log_stream_name)
response = client.put_log_events(logGroupName=log_group_name,
Expand All @@ -30,6 +35,5 @@
fragment = f"logsV2:log-groups/log-group/{log_group_name}/log-events/{encoded_stream_name}"
url = f"{base_url}?region=eu-west-2#{fragment}"


with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f"log-url={url}", file=fh)

0 comments on commit b47c95d

Please sign in to comment.