OSDN Git Service

perf report: Introduce --stdio-color to setup the color output mode selection
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 5 Jul 2016 14:14:38 +0000 (11:14 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Jul 2016 03:00:39 +0000 (00:00 -0300)
'perf report --stdio' will colorize entries with most hits and possibly
some other aspects of its output, but those colors gets suppressed if we
redirect the output to a non-tty, allow keeping the colors by adding a
new option, --stdio-color, now this use case will also output escape
sequences for colors:

  $ perf annotate --stdio-color | more

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-3iuawqjldu4i8gziot7e3d5n@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-report.txt
tools/perf/builtin-report.c

index 9cbddc2..2d17462 100644 (file)
@@ -265,6 +265,13 @@ OPTIONS
 
 --stdio:: Use the stdio interface.
 
+--stdio-color::
+       'always', 'never' or 'auto', allowing configuring color output
+       via the command line, in addition to via "color.ui" .perfconfig.
+       Use '--stdio-color always' to generate color even when redirecting
+       to a pipe or file. Using just '--stdio-color' is equivalent to
+       using 'always'.
+
 --tui:: Use the TUI interface, that is integrated with annotate and allows
         zooming into DSOs or threads, among other features. Use of --tui
        requires a tty, if one is not present, as when piping to other
index f6cb357..949e5a1 100644 (file)
@@ -817,6 +817,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
                    "Show raw trace event output (do not use print fmt or plugins)"),
        OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy,
                    "Show entries in a hierarchy"),
+       OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
+                            "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
+                            stdio__config_color, "always"),
        OPT_END()
        };
        struct perf_data_file file = {