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

feat(rainbowprint): Introduce colorful log prefixing #1007

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

LucaSeri
Copy link
Contributor

@LucaSeri LucaSeri commented Nov 15, 2023

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran make fmt on your commit series before opening this PR;
  • Updated relevant documentation.

Description of changes

This PR introduces the rainbowprint internal library that can be used to generate ANSI color codes. The library is used for kraft run and kraft log to optionally prefix all the logs with a colorful string, which is useful when looking at a stream generated by multiple unikernels:

kraft run --prefix "soo colorful" unikraft.org/helloworld:latest --plat qemu --arch x86_64

ss

@LucaSeri
Copy link
Contributor Author

Currently based on top of #984

@LucaSeri LucaSeri force-pushed the rainbow-print branch 2 times, most recently from 62255c9 to a05048e Compare November 20, 2023 08:51
@LucaSeri LucaSeri force-pushed the rainbow-print branch 2 times, most recently from 236bfd4 to cbe24b7 Compare November 23, 2023 14:19
@nderjung
Copy link
Member

nderjung commented Jan 8, 2024

Hi @LucaSeri, #984 is now merged 🎉 Could you please rebase?

This commit imports a customized colored text generator from [0] verbatim
and with LICENSE attribution.  The purpose for importing is to be able to
make adjustments whilst retaining base functionality.

[0]: https://github.com/docker/compose/blob/df70735/cmd/formatter/colors.go

Signed-off-by: Luca Seritan <luca.seritan@gmail.com>
Get rid of init in favour of lazily initializing
all the colors when they are first requested.

Signed-off-by: Luca Seritan <luca.seritan@gmail.com>
This commit introduces a generic log consumer interface
with a single implementation which can be used to prefix
all logs with a colorful annotation.

Signed-off-by: Luca Seritan <luca.seritan@gmail.com>
@LucaSeri
Copy link
Contributor Author

LucaSeri commented Jan 8, 2024

Thanks @nderjung! This is now ready for any final review 🚀

Introduce the option to prepend all logs with
a colorful prefix that can help distinguish
between log streams.

Signed-off-by: Luca Seritan <luca.seritan@gmail.com>
Introduce the option to prepend all logs with
a colorful prefix that can help distinguish
between log streams.

Signed-off-by: Luca Seritan <luca.seritan@gmail.com>
Copy link
Member

@nderjung nderjung left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks!

@nderjung nderjung merged commit 3bd2eca into unikraft:staging Jan 9, 2024
3 of 4 checks passed
@LucaSeri LucaSeri deleted the rainbow-print branch January 31, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

2 participants