public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Petr Mladek <pmladek@suse.cz>
Cc: Andy Whitcroft <apw@canonical.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] checkpatch: Make the output better readable
Date: Mon, 01 Jun 2015 11:02:42 -0700	[thread overview]
Message-ID: <1433181762.4861.29.camel@perches.com> (raw)
In-Reply-To: <1433168737-17009-1-git-send-email-pmladek@suse.cz>

On Mon, 2015-06-01 at 16:25 +0200, Petr Mladek wrote:
> I always have troubles to parse checkpatch.pl output when I check
> the whole patchset. It is hard to say which messages belongs to
> what patch.
> 
> This patch does few small changes to make the output look better
> for me:

As git and other utilities now use color by default, what do
you think about adding color for various message types?

And colorize only to the terminal, not any redirected output.

Maybe something like:

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c8032a0..12c43c6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,6 +9,7 @@ use strict;
 use POSIX;
 use File::Basename;
 use Cwd 'abs_path';
+use Term::ANSIColor qw(:constants);
 
 my $P = $0;
 my $D = dirname(abs_path($P));
@@ -1649,10 +1650,24 @@ sub report {
 		return 0;
 	}
 	my $line;
+	my $cprefix = $prefix;
+	my $clevel = $level;
+	my $ctype = $type;
+	if (-t STDOUT) {
+		$cprefix = GREEN . $prefix . RESET;
+		if ($level eq "ERROR") {
+			$clevel = RED . $level . RESET;
+		} elsif ($level eq "WARNING") {
+			$clevel = YELLOW . $level . RESET;
+		} else {
+			$clevel = GREEN . $level . RESET;
+		}
+		$ctype = GREEN . $type . RESET;
+	}
 	if ($show_types) {
-		$line = "$prefix$level:$type: $msg\n";
+		$line = "$cprefix$clevel:$ctype: $msg\n";
 	} else {
-		$line = "$prefix$level: $msg\n";
+		$line = "$cprefix$clevel: $msg\n";
 	}
 	$line = (split('\n', $line))[0] . "\n" if ($terse);
 



  parent reply	other threads:[~2015-06-01 18:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 14:25 [PATCH] checkpatch: Make the output better readable Petr Mladek
2015-06-01 15:50 ` Joe Perches
2015-06-02  9:13   ` Petr Mladek
2015-06-02  9:52     ` Joe Perches
2015-06-02 10:44       ` Petr Mladek
2015-06-02 20:49         ` Joe Perches
2015-06-01 18:02 ` Joe Perches [this message]
     [not found]   ` <CA+r1ZhjhF-n4Q2kfiV6mx1aUqbZNycNTJBkTgLTq9KivsawvdA@mail.gmail.com>
2015-06-01 18:22     ` Joe Perches
2015-06-02  9:26   ` Petr Mladek
2015-06-02  9:54     ` Joe Perches
2015-06-02 10:53     ` Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433181762.4861.29.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox