Skip to content

Commit d6069fe

Browse files
committed
fix(github): make multiline logs appear correctly in summary
1 parent 40f2b33 commit d6069fe

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • src/run/run_environment/github_actions

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
println!("::notice title=New CodSpeed Feature::{escaped_announcement}");
6163
return;
@@ -76,10 +78,10 @@ impl Log for GithubActionLogger {
7678
Level::Debug => "::debug::",
7779
Level::Trace => "::debug::[TRACE]",
7880
};
79-
let message_string = message.to_string();
80-
let lines = message_string.lines();
81-
// ensure that all the lines of the message have the prefix, otherwise GitHub Actions will not recognize the command for the whole string
82-
lines.for_each(|line| println!("{prefix}{line}"));
81+
// properly escape newlines so that GitHub Actions interprets them correctly
82+
// https://github.com/actions/toolkit/issues/193#issuecomment-605394935
83+
let message_string = message.to_string().replace('\n', "%0A");
84+
println!("{prefix}{message_string}");
8385
}
8486

8587
fn flush(&self) {

0 commit comments

Comments
 (0)