[FFmpeg-cvslog] r22946 - trunk/libavutil/log.c

James Darnley james.darnley
Fri Apr 23 14:26:04 CEST 2010


2010/4/23 M?ns Rullg?rd <mans at mansr.com>:
> James Darnley <james.darnley at gmail.com> writes:
>
>> 2010/4/23 M?ns Rullg?rd <mans at mansr.com>:
>>> A newline before the first 0 and normal indentation on those lines
>>> would be nice too.
>>
>> Better?
>>
>> Index: libavutil/log.c
>> ===================================================================
>> --- libavutil/log.c ? (revision 22952)
>> +++ libavutil/log.c ? (working copy)
>> @@ -24,6 +24,9 @@
>> ? * logging functions
>> ? */
>>
>> +#ifdef _WIN32
>> +#include <windows.h>
>> +#endif
>> ?#include <unistd.h>
>> ?#include "avutil.h"
>> ?#include "log.h"
>> @@ -33,12 +36,36 @@
>> ?#endif
>> ?int av_log_level = AV_LOG_INFO;
>>
>> -#if (!HAVE_ISATTY) || defined(WIN32)
>> +#if (!HAVE_ISATTY) || defined(_WIN32)
>
> Useless ().
>
>> ?#define isatty(s) 0
>> ?#endif
>>
>> ?#undef fprintf
>> ?static void colored_fputs(int color, const char *str){
>> +#ifdef _WIN32
>> + ? ?HANDLE console;
>> + ? ?CONSOLE_SCREEN_BUFFER_INFO console_info;
>> + ? ?int16_t attributes, win_color_conv[] = {
>
> That table should be static const.
>
>> + ? ? ? ?0,
>> + ? ? ? ?FOREGROUND_RED,
>> + ? ? ? ?FOREGROUND_GREEN,
>> + ? ? ? ?FOREGROUND_RED ?|FOREGROUND_GREEN,
>> + ? ? ? ?FOREGROUND_BLUE,
>> + ? ? ? ?FOREGROUND_RED ?|FOREGROUND_BLUE,
>> + ? ? ? ?FOREGROUND_GREEN|FOREGROUND_BLUE,
>> + ? ? ? ?FOREGROUND_RED ?|FOREGROUND_GREEN|FOREGROUND_BLUE };
>
> Please put the closing } on a new line.
>
>> + ? ?if ((color&15)==9) {
>> + ? ? ? ?fputs(str, stderr);
>> + ? ? ? ?return;
>> + ? ?}
>
> What's that all about?

Did that to not require detecting the original fg (text) colour and
then setting win_color_conv[9] to that value.  Why do that?  Because I
don't have grey text over my black bg and I don't want half of
ffmpeg's output in grey and the other in white.  Yes, I gave in and
decided that I wouldn't screw people with a white bg.

>> + ? ?console = GetStdHandle(STD_ERROR_HANDLE);
>> + ? ?GetConsoleScreenBufferInfo(console, &console_info);
>> + ? ?attributes = (console_info.wAttributes&0xF0) | win_color_conv[color&15];
>> + ? ?attributes |= (console_info.wAttributes&BACKGROUND_INTENSITY)?0:FOREGROUND_INTENSITY;
>> + ? ?SetConsoleTextAttribute(console, attributes);
>> + ? ?fputs(str, stderr);
>> + ? ?SetConsoleTextAttribute(console, console_info.wAttributes);
>
> This slab of code is ugly.
>
> How does this behave in a cygwin xterm?

Would you like more new lines in there

It does nothing.



More information about the ffmpeg-cvslog mailing list