From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753775AbbFASWT (ORCPT ); Mon, 1 Jun 2015 14:22:19 -0400 Received: from smtprelay0186.hostedemail.com ([216.40.44.186]:37695 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751546AbbFASWM (ORCPT ); Mon, 1 Jun 2015 14:22:12 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1461:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2197:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3653:3865:3866:3867:3868:3871:3872:3873:4321:4605:5007:6119:6261:7808:7903:10004:10400:10848:11232:11658:11914:12517:12519:12555:12679:12740:13095:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: iron94_871a5a98f4956 X-Filterd-Recvd-Size: 3131 Message-ID: <1433182927.4861.36.camel@perches.com> Subject: Re: [PATCH] checkpatch: Make the output better readable From: Joe Perches To: Jim Davis Cc: LKML , Petr Mladek , Andy Whitcroft , Andrew Morton Date: Mon, 01 Jun 2015 11:22:07 -0700 In-Reply-To: References: <1433168737-17009-1-git-send-email-pmladek@suse.cz> <1433181762.4861.29.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (adding back cc's) On Mon, 2015-06-01 at 11:14 -0700, Jim Davis wrote: > On Mon, Jun 1, 2015 at 11:02 AM, Joe Perches wrote: > > 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; > > + } > > Could colors be optional? Not everyone can distinguish green from > red, and some of us who can still prefer being colorless. (So to > speak.) Just as with git, piping though cat|less would eliminate colors, I suppose a --nocolor option could be added easily enough too. btw: it's not a patch, just a possibility/proposal.