We aim to integrate colorized and formatted log outputs for GeoIPS to enhance log readability for users. Currently, GeoIPS log outputs present a massive wall of text, making it challenging to distinguish important details at a glance.
Requirements
Easy to maintain
No changes in end user use for now, can introduce when CLI is merged to main
Easy to use
Not compute intensive (logging should be cheap)
Cross-platform compatible
Easily configured by CLI or config file
Compatible with Loki
Alternative Solutions
One alternative considered involved manually appending color escape codes and additional formatting directly within our logging mechanism, using a dictionary to pass more arguments for the formatting of logged messages. This approach is not ideal due to the potential complications with cross-platform compatibility and the burden of developing and maintaining custom code. This approach was suggested here: https://github.com/NRLMMD-GEOIPS/geoips/issues/476
Proposed Solution
Use rich. Rich supports various text formatting options, such as italicizing, folding, and underlining, alongside colorization, and offers a toolset for logging with colors/formatting.Rich is small (~2.3 MB), popular (approx. 50k stars, ~2k forks), active (updates in the last few months).
Lots of features, eg. "Rich can automatically highlight patterns in text, such as numbers, strings, collections, booleans, None, and a few more exotic patterns such as file paths, URLs and UUIDs."
And also can do this:
log.error("[bold red blink]Server is shutting down![/]", extra={"markup": True})
[ ] Implement line coloring (eg. just coloring "DEBUG" blue), with functionality turned OFF by default, and turned ON only by an environmental variable (temporary config option, this will be make obsolete when CLI is merged)
[ ] Profile for speed/compute cost
[ ] Document changes & Merge to main with functionality OFF by default
[ ] Develop handlers and formatters for file and console logging
[ ] Add functionality for word formatting (eg. "This is a bold word")
[ ] Implement command line options to manage the behavior of the new log output features
[ ] Re-profile for speed/compute cost
[ ] Document changes
[ ] Re-merge with new configuration options into CLI main branch
Colorized logs
Description
Requirements
Alternative Solutions
Proposed Solution
Use
rich
. Rich supports various text formatting options, such as italicizing, folding, and underlining, alongside colorization, and offers a toolset for logging with colors/formatting.Rich is small (~2.3 MB), popular (approx. 50k stars, ~2k forks), active (updates in the last few months).Rich has a colorized/formatted log handler: https://rich.readthedocs.io/en/stable/logging.html
Lots of features, eg. "Rich can automatically highlight patterns in text, such as numbers, strings, collections, booleans, None, and a few more exotic patterns such as file paths, URLs and UUIDs."
And also can do this:
All of which can be turned off. There's lots more too - see the docs here: https://rich.readthedocs.io/
Roadmap for Completion