Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorize SR output on CHECK success/failure #1654

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@
hide-default-footer
dense
data-test="output-messages"
/>
>
<template v-slot:item.message="{ item }">
<div :class="messageClass(item.message)">{{ item.message }}</div>
</template>
</v-data-table>
</v-card>
</div>
</template>
Expand Down Expand Up @@ -126,6 +130,15 @@ export default {
},
},
methods: {
messageClass(message) {
if (message.match(/CHECK:.*success with value.*after waiting/)) {
return 'openc3-green'
} else if (message.match(/CHECK:.*failed with value.*after waiting/)) {
return 'openc3-red'
} else {
return ''
}
},
downloadLog() {
const output = this.messages.map((message) => message.message).join('\n')
const blob = new Blob([output], {
Expand Down
6 changes: 5 additions & 1 deletion openc3-cosmos-script-runner-api/app/models/running_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,11 @@ def handle_output_io(filename = @current_filename, line_number = @current_line_n
begin
json = JSON.parse(out_line, :allow_nan => true, :create_additions => true)
time_formatted = Time.parse(json["@timestamp"]).sys.formatted if json["@timestamp"]
out_line = json["log"] if json["log"]
if json["log"]
out_line = json["log"]
elsif json["message"]
out_line = json["message"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure when we added 'message' as well as 'log' but this was causing the CHECK error messages to be unformatted json

end
rescue
# Regular output
end
Expand Down
2 changes: 2 additions & 0 deletions openc3-cosmos-script-runner-api/scripts/running_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ def handle_output_io(self, filename=None, line_number=None):
time_formatted = json_hash["@timestamp"]
if "log" in json_hash:
out_line = json_hash["log"]
if "message" in json_hash:
out_line = json_hash["message"]
except:
# Regular output
pass
Expand Down
Loading