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

Get rid of fluttered build job output and color errors #374

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ammernico
Copy link
Collaborator

No description provided.

@ammernico ammernico force-pushed the exit-status-colors branch 2 times, most recently from 063866d to 0161414 Compare April 30, 2024 14:49
@ammernico ammernico marked this pull request as draft April 30, 2024 15:13
@ammernico ammernico force-pushed the exit-status-colors branch 3 times, most recently from 2339aef to a337e8a Compare May 16, 2024 13:05
@ammernico ammernico changed the title Print exit messages in a colorful way Get rid of fluttered build job output and color errors May 16, 2024
@christophprokop
Copy link
Collaborator

tested updated version, looks much better now - thanks!

@ammernico ammernico force-pushed the exit-status-colors branch 2 times, most recently from e9bdda4 to 65bb663 Compare May 23, 2024 07:29
Signed-off-by: Nico Steinle <nico.steinle@eviden.com>
This will minimize text flutter when building many packages

```
- before:
[00:00:06] (100%): █████ | [endpoint-name/XXXXXXX XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX package-name package_version]: msg
- after:
[00:00:06] (100%): █████ | endpoint-name XXXXXXX XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ██ package_name  package_version msg
                           ^^^^^^^^^^^^^--- gets cut when longer than 6characters     ^^--- colored build status block
```

Signed-off-by: Nico Steinle <nico.steinle@eviden.com>
The change to this specific formatting was requested by many users
since it makes the output look cleaner

Signed-off-by: Nico Steinle <nico.steinle@eviden.com>
@ammernico ammernico marked this pull request as ready for review May 23, 2024 07:39
Copy link
Member

@primeos-work primeos-work left a comment

Choose a reason for hiding this comment

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

I didn't test it yet but based on the diff the new format looks acceptable. Some of the format/color changes make a lot of sense but there are also some that I'm not really sure about. The implementation and commit messages require a bit of work though.

@@ -12,7 +12,7 @@ compatibility = 1
# fit a 80 or 100 character wide terminal!
#
# This is also the default if the setting is not present.
progress_format = "[{elapsed_precise}] ({percent:>3}%): {bar:40.cyan/blue} | {msg}"
progress_format = "{elapsed_precise} {percent:>3}% {bar:5.cyan/blue} | {msg}"
Copy link
Member

Choose a reason for hiding this comment

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

If we change the example here that we also should change the default (s. comment above):

/// The default progress bar format
pub fn default_progress_format() -> String {
String::from("[{elapsed_precise}] ({percent:>3}%): {bar:40.cyan/blue} | {msg}")
}

@@ -38,6 +38,8 @@ use crate::job::JobResource;
use crate::job::RunnableJob;
use crate::log::LogItem;

pub const MAX_ENDPOINT_NAME_LENGTH: usize = 6;
Copy link
Member

Choose a reason for hiding this comment

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

We should try hard to avoid such magic constants. This one is especially a no-go as it depends on user defined endpoint names so we cannot simply cap the length to 6 here. One option would be to dynamically determine the max length by iterating over all configured endpoint names.

@@ -371,7 +373,6 @@ struct LogReceiver<'a> {
impl<'a> LogReceiver<'a> {
async fn join(mut self) -> Result<String> {
let mut success = None;

Copy link
Member

Choose a reason for hiding this comment

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

nit: Such unrelated changes should be avoided but it's kinda ok here.

@@ -420,12 +421,12 @@ impl<'a> LogReceiver<'a> {
self.bar.set_position(u as u64);
}
LogItem::CurrentPhase(ref phasename) => {
trace!("Setting bar phase to {}", phasename);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Why drop the trace output?

self.container_id_chrs,
self.job.uuid(),
"██".yellow(),
Copy link
Member

Choose a reason for hiding this comment

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

Hm, what's the motivation behind this (cc @christophprokop)? Seems to be a "Full Block" Unicode character (https://www.compart.com/en/unicode/U+2588). I'm not sure if it's really a good idea to put Unicode characters in the source code and output. Theoretically we'd have to check if the language and terminal supports this but I guess we can make Unicode support a requirement nowadays.

Comment on lines +575 to +576
"", // endpoint_name
"", // container_id
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is still WIP / didn't get finished?

Comment on lines +596 to +597
"", // endpoint_name
"", // container_id
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Comment on lines +662 to +663
"", // endpoint_name
"", // container_id
Copy link
Member

Choose a reason for hiding this comment

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

Again :P

Edit: Quite a few more occurrences throughout the rest of the file :o :D

self.jobdef.job.package().name(),
self.jobdef.job.package().version(),
msg = errmsg
msg = errmsg.yellow()
Copy link
Member

Choose a reason for hiding this comment

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

Question: Should the error message really be yellow instead of red? Is this because of the inherited/propagated errors?

self.jobdef.job.uuid(),
"██".white(),
Copy link
Member

Choose a reason for hiding this comment

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

nit: White might not be ideal for terminals with white backgrounds but I'm not sure if there's a better alternative.

@primeos-work
Copy link
Member

@christophprokop can you perhaps also provide motivation/background for or rather reasoning behind the output format changes?

The things that seem obvious:

  • Colorization to make the relevant parts (especially errors) easier recognizable
  • Shortening the progress bar to save space
  • Fixed length fields for a cleaner output structure (columnated, similar to a table)

What I'm not sure about:

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

Successfully merging this pull request may close these issues.

None yet

3 participants