Patch: Colored debug

Thiago Macieira thiago at kde.org
Mon Sep 3 15:06:53 BST 2007


On Monday 03 September 2007 10:28:56 Andreas Hartmetz wrote:
> On Monday 03 September 2007 08:02:50 Thiago Macieira wrote:
> > Olivier Goffart wrote:
> > >Le dimanche 2 septembre 2007, Martin Koller a écrit :
> > >> On Friday 31 August 2007, Jason 'vanRijn' Kasper wrote:
> > >> > Is it necessary to put this into the code directly when there are
> > >> > already standalone tools that do this?  I've been using grc to do
> > >> > this for years and it does the job quite well and it even has the
> > >> > ability to add custom configuration files (conf.kdebug perhaps?).
> > >> > For example, I use "grc tail -F
> > >> > /var/log/{maillog,messages,mail/info,mail,warn,acpid}&" and end up
> > >> > with a very nicely-colorized output shown here:
> > >> > http://www.flickr.com/photo_zoom.gne?id=1284102997&size=o
> > >> >
> > >> > Or am I missing something simple?
> > >>
> > >> I also think that postprocessing is a better way as you often might
> > >> need to check a logfile later via an editor to see what happened, and
> > >> if the logfile contains some ESC sequences, I don't think that it is
> > >> easy to read.
> > >
> > >Coloring is only activated if you are using a tty.
> > >If it is saved into a logfile, coloring is simply disabled.
> >
> > Please make colouring off by default. An environment variable enables it,
> > like with QTest (QTEST_COLORED=1).
>
> Have you *ever* had problems with ls's output coloring? Ever?
> And ls probably does just determine if it outputs to tty and disable colors
> if not. In any case, doing exactly as ls does should give exactly the same
> number of problems - practically none.

Agreed, but kDebug's output is NOT a tty, ever. It's outputting to 
qt_message_output. That one has the capability of determining whether its 
output is a TTY or not.

The test that Gof added for it has to go away. It's not thread-safe: you're 
not supposed to call qInstallMsgHandler once the program has started because 
that function isn't thread-safe, but QDebug/qDebug/kDebug/etc. are supposed 
to be.

If you find a way of determining if the output is going to a TTY without 
calling qInstallMsgHandler, be my guest.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070903/af3e3804/attachment.sig>


More information about the kde-core-devel mailing list