How can we highlight SQL code in some log files, with Emacs?
Sample log file:
[DEBUG][2016-05-26 09:04:51,714][FileHelper] - [realContextPath=[/server.xml]] [DEBUG][2016-05-26 10:24:22,369][DbConnectionImpl] - [DELETE FROM xct_log] [DEBUG][2016-05-26 11:00:46,925][DataSourceRestrictionConverter] - [parseRestrictions] [DEBUG][2016-05-26 10:24:22,476][DbConnectionImpl] - [UPDATE hlpdsk_step_log SET table_name= 'hxct_log' WHERE table_name='xct_log' AND pkey_value = 247296]
The goal would be to put a light yellow background behind SQL code, that is:
- code found between the last [...] (can be on multiple physical lines, as shown in the last line of the log sample), and
- code found on lines where the "source" (3rd bracket pair) is "DbConnectionImpl".
If possible, the yellow background should only be between those last 2 brackets, on the right lines.
(Originally posted on StackOverflow, but advised to post it here.)