bat icon indicating copy to clipboard operation
bat copied to clipboard

colorize lines in logs differently depending on importance

Open miguelbarao opened this issue 2 years ago • 1 comments

Thanks for the work you put into bat. I was considering using tail -f and bat to colorize the log of a running program. In many logs there are keywords indicating the importance of a line. For example INFO, WARNING, ERROR, CRITICAL, DEBUG. It would be useful to have the lines colored differently so that errors could be easily spotted. Would you be interested in supporting this feature?

miguelbarao avatar Apr 08 '22 16:04 miguelbarao

Thanks for the feedback. We had a short discussion on this at https://github.com/sharkdp/bat/issues/1605#issuecomment-813601215, but it should be possible to cater for both styles - log level word vs full line - with some color scheme customization if we tweak the log syntax to support it.

keith-hall avatar Apr 08 '22 17:04 keith-hall

Vim has a very nice syntax highlighting plugin with the following rules: https://github.com/MTDL9/vim-log-highlighting/blob/master/syntax/log.vim

Is it possible to integrate similar rules in bat?

Here is how my log looks when I use bat: Screenshot 2022-11-29 at 10 18 14 AM

And here are the same lines of log in Vim: Screenshot 2022-11-29 at 10 18 47 AM

MahdiNazemi avatar Nov 29 '22 18:11 MahdiNazemi