[Ffmpeg-devel] [PATCH] avutil/log output
Michael Niedermayer
michaelni
Thu Oct 19 10:56:58 CEST 2006
Hi
On Thu, Oct 19, 2006 at 10:10:55AM +0900, Alexey Sidelnikov wrote:
> When I'm working with ffmpeg, sometimes I have to tune supported codecs,
> formats and so on. The most convinient way for me to check the formats, for
> example, is
>
> ffmpeg -formats > formats.txt
>
> In the same manner I used to save help file:
>
> ffmpeg > help.txt
>
> But recently I noticed that not all help info gets into the file, something
> was still output into console. That is because "old" help uses just
> printf(), but new one - av_log(..., AV_LOG_INFO, ...). But av_log() always
> output everything into stderr, when printf() - into stdout. So I just fixed
> that in av_log() file, +
> changed #define AV_LOG_... into enum. Any
> objections?
yes changing #define AV_LOG_... into an enum while nice principle breaks the
API compatibility (think of #ifdef AV_LOG...), iam not sure if its worth it
but either way its a seperate issue and should be in a seperate patch
[...]
> -static void av_log_default_callback(void* ptr, int level, const char* fmt,
> va_list vl)
> +static void av_log_default_callback(void* ptr, enum AV_LOG_LEVEL level,
> const char* fmt, va_list vl)
> {
> static int print_prefix=1;
> AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
> + FILE* log_out_file = NULL;
> if(level>av_log_level)
> return;
> +
> + switch (level) {
> + case AV_LOG_QUIET:
> + break; // no output
wrong, if AV_LOG_QUIET<=av_log_level
> +
> + case AV_LOG_ERROR:
> + log_out_file = stderr;
> + break;
> +
> + case AV_LOG_INFO: case AV_LOG_DEBUG:
> + log_out_file = stdout;
totally breaks outputing to stdout, you would have the debug messages
embeded at random locations within your avi file ...
> + break;
> +
> + default:
> + av_log(ptr, AV_LOG_ERROR, "Unsupported log level %i", level);
> + exit(-1);
exit() is not acceptable in a lib, think of printf() calling exit for a
infinite floating point value
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel
mailing list