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

Combine multiple prints to a single one #1396

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Thomas1664
Copy link
Contributor

@Thomas1664 Thomas1664 commented Apr 30, 2024

The goal is to avoid interception with other prints from different threads.

Originally, I wanted to delete println() entirely, but it's used by print_error_message(). This function parses the given string to add error colorization. It's used to print e.g. JSON parsing errors.

@Thomas1664 Thomas1664 marked this pull request as ready for review April 30, 2024 12:13
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

It is true in the general case that we can't / don't want to buffer everything entirely before printing it. That needs big continuous memory buffers and can be detrimental to figuring out where things happen.

However, I don't think those concerns apply to the cases described here, so I'm inclined to take this. Thanks!

(I also don't think taking this implies anything about what we want to do across threads :) )

@@ -1437,28 +1437,33 @@ namespace vcpkg
}

template<class Message>
static void print_build_result_summary_line(Message build_result_message, int count)
static void append_build_result_summary_line(Message build_result_message, int count, LocalizedString& str)
Copy link
Member

Choose a reason for hiding this comment

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

In a generic environment I would oppose a function including the '\n' because it's very easy to add one on later and a pain to deal with if one is already there. However, in this case, it's a static function clearly used only immediately below where the newline is necessary, so I think it's OK.

}
to_print.append_raw('\n');
Copy link
Member

Choose a reason for hiding this comment

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

Review/note: This isn't a change, used to be on 455

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants