wapty
wapty copied to clipboard
Improve logger to support HTML colors
Logger now outputs ANSI escape sequences to stdout.
It should be possible to set an io.Writer in the cli/lg package where the logger will write HTML formatted output. (it should do nothing if such writer is not set)
When now a line of output is foo \x1b[31mbar\x1b[0m
It should become foo <span style="color:#A00">bar</span>,
Some example here: https://github.com/rburns/ansi-to-html/blob/master/src/ansi_to_html.js#L203
It would be better to wrap calls to log to directly output HTML-formatted outputs instead of converting it.
To achieve this a list as this one could be used, but for HTML instead of ANSI.
Implementing an "HTMLString" method like ShortString should work.
Please cover your code with tests.