rtla/timerlat: Use pretty formatting only on interactive tty
authorDaniel Bristot de Oliveira <bristot@kernel.org>
Wed, 24 Apr 2024 14:36:52 +0000 (16:36 +0200)
committerDaniel Bristot de Oliveira <bristot@kernel.org>
Wed, 15 May 2024 13:13:57 +0000 (15:13 +0200)
commitf5c0cdad6684aa4212346f48554636ec2ab98434
tree571a11108a4be691671c0dd2896c84517e2f3ebf
parenta40e5e4dd0207485dee75e2b8e860d5853bcc5f7
rtla/timerlat: Use pretty formatting only on interactive tty

timerlat top does some background/font color formatting. While useful
on terminal, it breaks the output on other formats. For example, when
piping the output for pastebin tools, the format strings are printed
as characters. For instance:

  [2;37;40m                                     Timer Latency                                              [0;0;0m
    0 00:00:01   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)
  [2;30;47mCPU COUNT      |      cur       min       avg       max |      cur       min       avg       max[0;0;0m
    0 #1013      |        1         0         1        54 |        5         2         4        57
    1 #1013      |        3         0         1        10 |        6         2         4        15

To avoid this problem, do the formatting only if running on a tty,
and in !quiet mode.

Link: https://lkml.kernel.org/r/8288e1544ceab21557d5dda93a0f00339497c649.1713968967.git.bristot@kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
tools/tracing/rtla/src/timerlat_top.c