After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 474055 - Default to using color only when tty
Default to using color only when tty
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-09-05 22:39 UTC by Steve Fink
Modified: 2007-09-13 19:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Turn off color when stdout not a tty (556 bytes, patch)
2007-09-05 22:39 UTC, Steve Fink
none Details | Review
updated patch (640 bytes, patch)
2007-09-06 05:17 UTC, Sebastian Dröge (slomo)
rejected Details | Review
Document less -R for clueless people like me (827 bytes, patch)
2007-09-13 18:27 UTC, Steve Fink
committed Details | Review

Description Steve Fink 2007-09-05 22:39:00 UTC
The colors on the debug output are nice when displaying to a terminal, but a pain when piping through a pager (as is often the case, because the output is so voluminous.) I would prefer it if the default was to use color only if the output is a terminal.

I'm attaching a patch (hopefully; if I figure out how).
Comment 1 Steve Fink 2007-09-05 22:39:41 UTC
Created attachment 95026 [details] [review]
Turn off color when stdout not a tty
Comment 2 Sebastian Dröge (slomo) 2007-09-06 05:04:08 UTC
isatty() is not really portable AFAIK and only exists on Unix-like systems (and needs unistd.h).
So the isatty() part must be wrapped in #ifdef HAVE_UNISTD_H.
Comment 3 Sebastian Dröge (slomo) 2007-09-06 05:15:09 UTC
Also the debug output is sent to stderr, not stdout by default. But I'm not sure that this simple patch is enough, one could register their own debug output functions or set another error message handler for g_printerr() and this could in theory support colors.
Comment 4 Sebastian Dröge (slomo) 2007-09-06 05:17:35 UTC
Created attachment 95032 [details] [review]
updated patch
Comment 5 Tim-Philipp Müller 2007-09-06 09:24:41 UTC
Both

  GST_DEBUG=*:5 gst-inspect-0.10 2>&1 | less -R

and

  GST_DEBUG=*:5 gst-inspect-0.10 2>&1 | more


show the colours just fine for me, and it'd be nice if that behaviour was kept IMHO.  Same for output to file and subsequent viewing in colour-aware pager.

Maybe add another environment variable or abuse GST_DEBUG_NO_COLOR in connection with the isatty check?
Comment 6 Sebastian Dröge (slomo) 2007-09-06 12:27:48 UTC
A new env variable doesn't make sense IMHO, one could simply use the old one to disable the colors then. I guess we can close this bug as there can't be any auto detection of what the user wants
Comment 7 Steve Fink 2007-09-06 19:32:08 UTC
I like Tim's idea. In more detail, it would be either creating a variable

  GST_DEBUG_COLOR_IF_TTY or GST_DEBUG_COLOR_ONLY_IF_TTY

or abusing GST_DEBUG_NO_COLOR by allowing the value

  notty

to mean "no color if not tty" (the double negative is unfortunate).

On the other hand, I think I no longer care all that much, because thanks to Tim I now know of the existence of the -R option. And the other time when it's annoying is when I'm running within emacs, and there the tty check won't help anyway. (Yes, I'm sure emacs has a terminal mode that would handle the colors too. But I'd rather not go to that much trouble.)
Comment 8 Tim-Philipp Müller 2007-09-08 20:03:33 UTC
Ok, let's WONTFIX this then :)
Comment 9 Steve Fink 2007-09-13 18:27:23 UTC
Created attachment 95537 [details] [review]
Document less -R for clueless people like me
Comment 10 Steve Fink 2007-09-13 18:27:55 UTC
But that would be too easy! I'm trying to file down all the rough edges I
encounter in my explorations of gstreamer, and this was one fairly minor such
annoyance. So please consider the attached doc patch so the next person to come
along with as little clue as I have won't need to run into the same thing.
Comment 11 Tim-Philipp Müller 2007-09-13 19:28:14 UTC
Wooh, a docs patch! Thanks, committed:

 2007-09-13  Tim-Philipp Müller  <tim at centricular dot net>

        Patch by: Steve Fink  <sphink gmail com>

        * docs/manual/appendix-checklist.xml:
          Mention less -R switch in the section about debug output (#474055).