Skip to content

Conversation

tylerslaton
Copy link
Collaborator

@tylerslaton tylerslaton commented Jul 15, 2022

Summary

Using the pretty_env_logger to add some color into the application. Considered using the crate recommended in the issue but thought that using fully-featured logger would make more sense. This entailed a few changes:

  1. Introducing the log crate and an implementation of it in the form of pretty_env_logger.
  2. Added a new flag --log-level (or -l for short) to allow a user to define the level. Defaults to info.
  3. Updated our println!() or eprintln!() calls to use structured calls to the pretty_env_logger macros.
  4. Added some emojis for flavor 🥇

Preview

Most of the changes here are visual, so here are a few example of how the CLI looks when running it.

Note: I'm not tied to any of the emojis, feel free to request that they be removed if we're not a fan. That being said, I personally like them!

Default log level:

The log level by default will be info which is intended to just display the essential information.

$ dcp quay.io/tyslaton/sample-catalog:v0.0.4 -d /tmp/dcp_test_dir

Screen Shot 2022-07-14 at 9 51 21 PM

Defined log level:

By defining the log level as debug we can see a lot more of the underlying processes taking place.

$ dcp quay.io/tyslaton/sample-catalog:v0.0.4 -d /tmp/dcp_test_dir --log-level debug

Screen Shot 2022-07-14 at 9 50 35 PM

Error output

$ dcp quay.io/tyslaton/sample-catalog:v0.0. -d /tmp/dcp_test_dir

Screen Shot 2022-07-14 at 9 51 42 PM

Closes #15
Closes #3

@tylerslaton tylerslaton requested review from timflannagan and exdx July 15, 2022 02:15
Copy link
Owner

@exdx exdx left a comment

Choose a reason for hiding this comment

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

Great job! The logging looks much better.

Closes #15
Closes #3 (I think we can use emojis instead of colorizing the output)

Copy link
Collaborator

@timflannagan timflannagan left a comment

Choose a reason for hiding this comment

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

Can we use GNU style CLI flags now that #10 merged?

Signed-off-by: Tyler Slaton <tyslaton@redhat.com>
@exdx exdx merged commit 726f9fe into exdx:main Jul 15, 2022
@tylerslaton tylerslaton deleted the add-color branch July 15, 2022 13:43
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.

Restructure the logging Add colorized output
3 participants