I have python's logging module configured with all sorts of colour-coded lines.
However the colours are lost when using a file handler to export to a log file and then tail -f to follow the file live.
Is there any way to export the colour formatting to the output file such that tail, less and co. could properly show it?
The configuration on the python side is done by something like:
coloredlogs.install(
logger=_logger, fmt='%(asctime)s %(message)s', use_chroot=False,
field_styles={'asctime': {'color': 'cyan'}}, datefmt='%d.%m.%Y %H:%M',
level_styles={
'info': {'color': 'white', 'bold': False},
'warn': {'color': 'blue', 'bold': True},
'error': {'color': 'magenta', 'bold': False}
}
)
Thanks