Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this PR you will be able to easily colorize the CLI
Resolves #10
Docs?
@Enovotny
Should decide if we want both developer and enduser docs.
If developer docs do I put those in CONTRIBUTING with the below howto?
If enduser, would you like to see a page in addition to what would present automatically from the site builder made by the args?
i.e. something explaining the colors and when/why you might disable them (file based logs)
PR Details
I started with blob which will dynamically figure out if an object is JSON and format it (screenshot below)
I did have to hook into the logger to try and catch the logs at a low level.
This also made it so you do not have to pass the no-color optione everywhere.
This introduces
log-fileandlog-levelarguments.Where you would call it like this:
Right after cwms-cli. Keeping the blob/list arg list from looking like a book.
I have it coloring the log level by default in 4 different colors.
But to explicitly color a log item with JSON you can do this:
You can also arbitrarily color various parts of text with
c("some text", "BLUE")or
logging.info(c("hello", "GREEN") + " " + c("world", "BLUE"))which would give
Libraries
I went with Colorama, seemed very popular!