Open evrose54 opened 2 months ago
Color! All the way 🔴 🟢 🔵
Instead of implementing something like
color_log_output(print_func, *messages, **kwargs)
could we use something like termcolor
, rich
or blessings
?
eg. we could do this: log.info(colored("message", "red"))
(using syntax from termcolor
) or even
log_with_emphasis(LOG.info, *messages, color_func=color("red"))
This would mean we don't have to worry about cross-platform compatibility, maintaining the code, etc. (all the usual benefits of using open source external code).
It also allows us to do fun stuff like:
without having to write extra code to support it.
Requested Update
Description
GeoIPS currently has a logging utility called
log_with_emphasis
, which logs text in an emphasized manner. An example of what the function would output is shown below. This is a nice utility to have, but could be expanded on more. It would be nice to have a utility function that makes use of Colorama's colored text / background to emphasize certain parts of the log output, highlight warnings, etc.An example of a colored utility function could look something like this:
Where kwargs is a dictionary of keyword arguments. This dictionary would look something like this:
An example of how this function could be called would look like this:
If none of those kwargs were to be specified, we'd just default to a certain argument. This could ultimately replace the
log_with_emphasis
function if we wanted, or we could add a new utility function that would implement what I specified above.Background and Motivation
This stems from discussions we've had about the
log_with_emphasis
function. See #377.Alternative Solutions
Leave the code as is