doublep/logview

Color surrounding portions of log lines

Closed this issue · 8 comments

How do I add color markers to my log format? My log lines look like:

[THREAD] �[0m[LEVEL] [TIMESTAMP] [NAME]: MESSAGE�[0m

The color before level is different for different levels.

I don't understand the question.

After [THREAD] and before [LEVEL] there are a few characters that indicate a color. The color isn't important to me, but it is making it where my format isn't recognized, because I am unsure how to ignore those characters. So my question is how to I write a format specifier that is like the above, but ignores those characters? My current specifier is

     ("MYLOG"
       (format . "[THREAD] [LEVEL] [TIMESTAMP] [NAME]: MESSAGE")
       (levels . "MYLEVELS")
       (timestamp "MYTIME")
       (aliases)))

Obviously that won't work.

If the characters are the same in all cases, you can just include them verbatim into the format. Otherwise you can try using special placeholder IGNORED. Currently there is no way to restrict what exactly is ignored, it defaults to regexp [^ \t\n]+ unless at the very end, then it is .+.

The following doesn't seem to work.

   ("MYLOG"
       (format . "[THREAD] IGNORED[LEVEL] [TIMESTAMP] [NAME]: MESSAGE")
       (levels . "MYLEVELS")
       (timestamp "MYTIME")
       (aliases)))

BTW, things work if I don't have the color in the log line.

Post a few sample lines of your logfile.

[lidar_calibration_server-1] �[0m[INFO] [1662144428.761581617] [iris_lidar_odometry_calibration.lidar_calibration_server]: Received request to begin calibration�[0m
[lidar_calibration_server-1] �[0m[INFO] [1662144428.761992557] [iris_lidar_odometry_calibration.lidar_calibration_server]: Beginning calibration�[0m
[lidar_calibration_server-1] �[0m[INFO] [1662144428.762039831] [iris_lidar_odometry_calibration.lidar_calibration_server]: Beginning data collection and calibration�[0m
[lidar_calibration_server-1] �[0m[INFO] [1662144428.762158735] [iris_lidar_odometry_calibration.lidar_calibration_server]: Waiting for data to begin calibration�[0m
[lidar_calibration_server-1] �[31m[ERROR] [1662144438.762401597] [iris_lidar_odometry_calibration.lidar_calibration_server]: Timeout while waiting for data�[0m
[lidar_calibration_server-1] �[31m[ERROR] [1662144438.762591075] [iris_lidar_odometry_calibration.lidar_calibration_server]: Failed to calibrate LiDAR: TIMEOUT�[0m

Unfortunately it seems like the browser mangles this a bit.

Logview is confused by [ in the part that should be ignored. The problem is that the ignored part is also supposed to be terminated by that character. As a workaround you could try something like this:

[THREAD] �[IGNORED[LEVEL] [TIMESTAMP] [NAME]: MESSAGE"

That seems to have done the trick. Thanks.