Simon icon Simon
Flexible server monitoring

Changed text before and after

Is there a way to output the changed text/characters with the surrounding text?

For example let's say:
"...this is a test text that is short..." has changed into "...this is a great text that is short...".
The Block filter would normally output the difference as: "grea". Is there a way to output the difference as: "is a great text"?

Also is there a way to output the changed text before and after the change? So the final output would look like this:

" a test text..." was changed into " a great text..."


David Sinclair's picture

Re: Changed text before and after

That was actually requested a year ago, and it's high on my feature suggestions list. But hasn't been added yet.

If you're familiar with scripting, it should in theory be possible to do it now in a script-based filter, by looking at the {ServiceResponseText} variable (which has the full text) and finding the {FilterOutputText} (output from the previous filter) and including more context via the script. But that's beyond my meagre scripting ability.

Otherwise, you can wait for me to add a filter variable and/or filter plugin to do this. Since there's been another request for it, I'll bump it up the priority queue, so it might get included in version 3.6 (though no promises; I haven't decided on the features for that yet).

Re: Changed text before and after

Yes that would be a killer feature: To output the two versions (before and after change) of the entire text belonging to each line that has changed, and maybe highlight the changed text in it.
Hope it makes it to ver. 3.6 or Simon Express.

David Sinclair's picture

Re: Changed text before and after

Good news: version 3.7 (in beta soon) has a new Context filter, to output more context around the output of a previous filter. You can choose a number of characters or a delimiter (or both) to extend the context before and after the text.

There are a number of new filter variables to support this, which may be useful for other filters or notifiers too.