0

I'm trying to integrate PVS-Studio analysis into CI for my homework. Everything seems to work fine except log printing; I want warnings to be colored or highlighted in some other way.

The best I could think of is to use plog-converter to output in html format and then use elinks -dump -dump-color-mode 1 to output that in terminal but it looks kinda weird.

Is there a better way to do it?

Amomum
  • 6,217
  • 8
  • 34
  • 62

2 Answers2

1

I think the best way is to modify the source of the plog-converter. The source code of the utility is published on GitHub so that users can expand the functionality for their tasks.

0

Since plog-converter can't do it out of the box and modifying its source code is a bit extreme, I decided to highlight output myself.

After a bit of a fiddling with syntax highlighting in terminal I found out that the simplest way is just using grep kinda like this:

plog-converter -t errorfile project.log | \
 GREP_COLOR='01;31' grep -E --color=always 'error:|$' | \
 GREP_COLOR='01;33' grep -E --color=always 'warning:|$'

I suppose errorfile format should only containt "errors" and "warning" so this colorizes just these two words with two different colors

Amomum
  • 6,217
  • 8
  • 34
  • 62