Readability of logs printed to stdout can be improved by using colors
Proof of concept implementation, which changes color of time:
class Colors:
GREEN = "\033[92m"
END = "\033[0m"
class LoggerWrapper:
__FORMATTER = logging.Formatter(
f"{Colors.GREEN}%(asctime)s{Colors.END} [%(levelname)s] %(message)s (%(filename)s:%(lineno)s)"
)
This is just an example, I don't want to have time printed in green
Hardest part of this feature are:
- create good design, which will improve readability and would be pleasant for eye
😄 - if you will want to print warning messages with yellow color note few things. It can be tricky to implement, because you have same format for all type of logs.
extra
parameter oflogging.log
can be helpful to implement it.
Edited by Piotr Batko