[FFmpeg-devel] Allow to force colored output
Etienne Buira
etienne.buira.lists
Sun Nov 14 15:02:58 CET 2010
On Sun, Nov 14, 2010 at 02:44:02PM +0100, Etienne Buira wrote:
> On Sun, Nov 14, 2010 at 02:23:29PM +0100, Stefano Sabatini wrote:
> > On date Sunday 2010-11-14 14:05:03 +0100, Etienne Buira encoded:
> > > Hi.
> > >
> > > Allow to force colored output even if stderr doesn't look to sanely
> > > interpret it.
> > >
> > > Regards.
> >
> > > Index: libavutil/log.c
> > > ===================================================================
> > > --- libavutil/log.c (revision 25751)
> > > +++ libavutil/log.c (working copy)
> > > @@ -66,6 +66,7 @@
> > > #else
> > > use_color= 0;
> > > #endif
> > > + use_color = use_color || getenv("FORCE_COLOR");
> > > }
> > >
> > > if(use_color){
> > > Index: doc/fftools-common-opts.texi
> > > ===================================================================
> > > --- doc/fftools-common-opts.texi (revision 25751)
> > > +++ doc/fftools-common-opts.texi (working copy)
> > > @@ -84,6 +84,7 @@
> > >
> > > By default the program logs to stderr, if coloring is supported by the
> > > terminal, colors are used to mark errors and warnings. Log coloring
> > > -can be disabled setting the environment variable @env{NO_COLOR}.
> > > +can be disabled setting the environment variable @env{NO_COLOR}, or
> > > +can be forced setting the environment variable @env{FORCE_COLOR}.
> >
> > We should provide a namespace even in this case, I suggest:
> > FFMPEG_NO_COLOR
> > FFMPEG_FORCE_COLOR
>
> Done, but might break for people who use NO_COLOR yet.
>
> > Also can you say why do you need this?
>
> My usecase is to save ffmpeg's output (ffmpeg ... > log 2>&1), but still
> having nice colors.
Sorry for the noise, this one should actually not screw up things for
win32.
-------------- next part --------------
Index: libavutil/log.c
===================================================================
--- libavutil/log.c (revision 25751)
+++ libavutil/log.c (working copy)
@@ -55,16 +55,16 @@
#if defined(_WIN32) && !defined(__MINGW32CE__)
CONSOLE_SCREEN_BUFFER_INFO con_info;
con = GetStdHandle(STD_ERROR_HANDLE);
- use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR");
+ use_color = (con != INVALID_HANDLE_VALUE) && (!getenv("FFMPEG_NO_COLOR") || getenv("FFMPEG_FORCE_COLOR"));
if (use_color) {
GetConsoleScreenBufferInfo(con, &con_info);
attr_orig = con_info.wAttributes;
background = attr_orig & 0xF0;
}
#elif HAVE_ISATTY
- use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2);
+ use_color= (getenv("TERM") && !getenv("FFMPEG_NO_COLOR") && isatty(2)) || getenv("FFMPEG_FORCE_COLOR");
#else
- use_color= 0;
+ use_color= !!getenv("FFMPEG_FORCE_COLOR");
#endif
}
Index: doc/fftools-common-opts.texi
===================================================================
--- doc/fftools-common-opts.texi (revision 25751)
+++ doc/fftools-common-opts.texi (working copy)
@@ -84,6 +84,8 @@
By default the program logs to stderr, if coloring is supported by the
terminal, colors are used to mark errors and warnings. Log coloring
-can be disabled setting the environment variable @env{NO_COLOR}.
+can be disabled setting the environment variable @env{FFMPEG_NO_COLOR},
+or can be forced setting the environment variable
+ at env{FFMPEG_FORCE_COLOR}.
@end table
More information about the ffmpeg-devel
mailing list