Skip to content

Commit c6a4fb9

Browse files
committed
fix(github): make multiline logs appear correctly in summary
1 parent 3515e1a commit c6a4fb9

File tree

1 file changed

+6
-4
lines changed
  • src/run/run_environment/github_actions

1 file changed

+6
-4
lines changed

src/run/run_environment/github_actions/logger.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ impl Log for GithubActionLogger {
5656
}
5757

5858
if let Some(announcement) = get_announcement_event(record) {
59+
// properly escape newlines so that GitHub Actions interprets them correctly
60+
// https://github.com/actions/toolkit/issues/193#issuecomment-605394935
5961
let escaped_announcement = announcement.replace('\n', "%0A");
6062
// TODO: make the announcement title configurable
6163
println!("::notice title=New CodSpeed Feature::{escaped_announcement}");
@@ -77,10 +79,10 @@ impl Log for GithubActionLogger {
7779
Level::Debug => "::debug::",
7880
Level::Trace => "::debug::[TRACE]",
7981
};
80-
let message_string = message.to_string();
81-
let lines = message_string.lines();
82-
// ensure that all the lines of the message have the prefix, otherwise GitHub Actions will not recognize the command for the whole string
83-
lines.for_each(|line| println!("{prefix}{line}"));
82+
// properly escape newlines so that GitHub Actions interprets them correctly
83+
// https://github.com/actions/toolkit/issues/193#issuecomment-605394935
84+
let message_string = message.to_string().replace('\n', "%0A");
85+
println!("{prefix}{message_string}");
8486
}
8587

8688
fn flush(&self) {

0 commit comments

Comments
 (0)