[Ffmpeg-devel] [PATCH] avutil/log output
Alexey Sidelnikov
avs99
Thu Oct 19 03:10:55 CEST 2006
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?
Alexey
Index: log.c
===================================================================
--- log.c (revision 6681)
+++ log.c (working copy)
@@ -26,32 +26,54 @@
#include "avutil.h"
-int av_log_level = AV_LOG_INFO;
+enum AV_LOG_LEVEL av_log_level = AV_LOG_INFO;
-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
+
+ case AV_LOG_ERROR:
+ log_out_file = stderr;
+ break;
+
+ case AV_LOG_INFO: case AV_LOG_DEBUG:
+ log_out_file = stdout;
+ break;
+
+ default:
+ av_log(ptr, AV_LOG_ERROR, "Unsupported log level %i", level);
+ exit(-1);
+ }
+
+ if (log_out_file == NULL)
+ return;
+
#undef fprintf
if(print_prefix && avc) {
- fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc);
+ fprintf(log_out_file, "[%s @ %p]", avc->item_name(ptr), avc);
}
#define fprintf please_use_av_log
print_prefix= strstr(fmt, "\n") != NULL;
- vfprintf(stderr, fmt, vl);
+ vfprintf(log_out_file, fmt, vl);
}
#if LIBAVUTIL_VERSION_INT < (50<<16)
-static void (*av_log_callback)(void*, int, const char*, va_list) =
av_log_default_callback;
+static void (*av_log_callback)(void*, enum AV_LOG_LEVEL, const char*,
va_list) = av_log_default_callback;
#else
-void (*av_vlog)(void*, int, const char*, va_list) =
av_log_default_callback;
+void (*av_vlog)(void*, enum AV_LOG_LEVEL, const char*, va_list) =
av_log_default_callback;
#endif
-void av_log(void* avcl, int level, const char *fmt, ...)
+void av_log(void* avcl, enum AV_LOG_LEVEL level, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
@@ -60,22 +82,22 @@
}
#if LIBAVUTIL_VERSION_INT < (50<<16)
-void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
+void av_vlog(void* avcl, enum AV_LOG_LEVEL level, const char *fmt, va_list
vl)
{
av_log_callback(avcl, level, fmt, vl);
}
-int av_log_get_level(void)
+enum AV_LOG_LEVEL av_log_get_level(void)
{
return av_log_level;
}
-void av_log_set_level(int level)
+void av_log_set_level(enum AV_LOG_LEVEL level)
{
av_log_level = level;
}
-void av_log_set_callback(void (*callback)(void*, int, const char*,
va_list))
+void av_log_set_callback(void (*callback)(void*, enum AV_LOG_LEVEL, const
char*, va_list))
{
av_log_callback = callback;
}
Index: log.h
===================================================================
--- log.h (revision 6681)
+++ log.h (working copy)
@@ -38,25 +38,28 @@
/* av_log API */
-#define AV_LOG_QUIET -1
-#define AV_LOG_ERROR 0
-#define AV_LOG_INFO 1
-#define AV_LOG_DEBUG 2
+enum AV_LOG_LEVEL {
+ AV_LOG_QUIET = -1,
+ AV_LOG_ERROR = 0,
+ AV_LOG_INFO = 1,
+ AV_LOG_DEBUG = 2
+};
+
extern int av_log_level;
#ifdef __GNUC__
-extern void av_log(void*, int level, const char *fmt, ...) __attribute__
((__format__ (__printf__, 3, 4)));
+extern void av_log(void*, enum AV_LOG_LEVEL level, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
#else
-extern void av_log(void*, int level, const char *fmt, ...);
+extern void av_log(void*, enum AV_LOG_LEVEL level, const char *fmt, ...);
#endif
#if LIBAVUTIL_VERSION_INT < (50<<16)
-extern void av_vlog(void*, int level, const char *fmt, va_list);
-extern int av_log_get_level(void);
-extern void av_log_set_level(int);
-extern void av_log_set_callback(void (*)(void*, int, const char*,
va_list));
+extern void av_vlog(void*, enum AV_LOG_LEVEL level, const char *fmt,
va_list);
+extern enum AV_LOG_LEVEL av_log_get_level(void);
+extern void av_log_set_level(enum AV_LOG_LEVEL);
+extern void av_log_set_callback(void (*)(void*, enum AV_LOG_LEVEL, const
char*, va_list));
#else
-extern void (*av_vlog)(void*, int, const char*, va_list);
+extern void (*av_vlog)(void*, enum AV_LOG_LEVEL, const char*, va_list);
#endif
#endif /* LOG_H */
begin 666 libavutil_log.patch
M26YD97 at Z(&QO9RYC#0H]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]#0HM+2T@;&]G
M+F,)*')E=FES:6]N(#8V.#$I#0HK*RL@;&]G+F,)*'=O<FMI;F<@8V]P>2D-
M"D! ("TR-BPS,B K,C8L-30 at 0$ -"B *("-I;F-L=61E(")A=G5T:6PN:"(*
M( HM:6YT(&%V7VQO9U]L979E;" ]($%67TQ/1U])3D9/.PHK96YU;2!!5E],
M3T=?3$5614P at 879?;&]G7VQE=F5L(#T at 059?3$]'7TE.1D\["B *+7-T871I
M8R!V;VED(&%V7VQO9U]D969A=6QT7V-A;&QB86-K*'9O:60J('!T<BP@:6YT
M(&QE=F5L+"!C;VYS="!C:&%R*B!F;70L('9A7VQI<W0@=FPI"BMS=&%T:6,@
M=F]I9"!A=E]L;V=?9&5F875L=%]C86QL8F%C:RAV;VED*B!P='(L(&5N=6T@
M059?3$]'7TQ%5D5,(&QE=F5L+"!C;VYS="!C:&%R*B!F;70L('9A7VQI<W0@
M=FPI"B!["B @(" @<W1A=&EC(&EN="!P<FEN=%]P<F5F:7@],3L*(" @("!!
M5D-L87-S*B!A=F,]('!T<B _("HH059#;&%S<RHJ*7!T<B Z($Y53$P["BL@
M(" @1DE,12H@;&]G7V]U=%]F:6QE(#T at 3E5,3#L*(" @("!I9BAL979E;#YA
M=E]L;V=?;&5V96PI"B @(" @(" @(')E='5R;CL**PHK(" @('-W:71C:" H
M;&5V96PI('L**R @(" @(" @8V%S92!!5E],3T=?455)150Z"BL@(" @(" @
M(" @("!B<F5A:SL)+R\@;F\@;W5T<'5T"BL**R @(" @(" @8V%S92!!5E],
M3T=?15)23U(Z"BL@(" @(" @(" @("!L;V=?;W5T7V9I;&4@/2!S=&1E<G([
M"BL@(" @(" @(" @("!B<F5A:SL**PHK(" @(" @("!C87-E($%67TQ/1U])
M3D9/.B!C87-E($%67TQ/1U]$14)51SH**R @(" @(" @(" @(&QO9U]O=71?
M9FEL92 ]('-T9&]U=#L**R @(" @(" @(" @(&)R96%K.PHK"BL@(" @(" @
M(&1E9F%U;'0Z"BL@(" @(" @(" @("!A=E]L;V<H<'1R+"!!5E],3T=?15)2
M3U(L(")5;G-U<'!O<G1E9"!L;V<@;&5V96P@)6DB+"!L979E;"D["BL@(" @
M(" @(" @("!E>&ET*"TQ*3L**R @(" @(" @?0HK"BL@(" @:68@*&QO9U]O
M=71?9FEL92 ]/2!.54Q,*0HK(" @(" @("!R971U<FX["BL*("-U;F1E9B!F
M<')I;G1F"B @(" @:68H<')I;G1?<')E9FEX("8F(&%V8RD@>PHM(" @(" @
M(" @(" @9G!R:6YT9BAS=&1E<G(L(");)7, at 0" E<%TB+"!A=F,M/FET96U?
M;F%M92AP='(I+"!A=F,I.PHK(" @(" @(" @(" @9G!R:6YT9BAL;V=?;W5T
M7V9I;&4L(");)7, at 0" E<%TB+"!A=F,M/FET96U?;F%M92AP='(I+"!A=F,I
M.PH@(" @('T*("-D969I;F4 at 9G!R:6YT9B!P;&5A<V5?=7-E7V%V7VQO9PH@
M"B @(" @<')I;G1?<')E9FEX/2!S=')S='(H9FUT+" B7&XB*2 A/2!.54Q,
M.PH@"BT@(" @=F9P<FEN=&8H<W1D97)R+"!F;70L('9L*3L**R @("!V9G!R
M:6YT9BAL;V=?;W5T7V9I;&4L(&9M="P@=FPI.PH@?0H@"B C:68 at 3$E"0595
M5$E,7U9%4E-)3TY?24Y4(#P@*#4P/#PQ-BD*+7-T871I8R!V;VED("@J879?
M;&]G7V-A;&QB86-K*2AV;VED*BP@:6YT+"!C;VYS="!C:&%R*BP@=F%?;&ES
M="D@/2!A=E]L;V=?9&5F875L=%]C86QL8F%C:SL**W-T871I8R!V;VED("@J
M879?;&]G7V-A;&QB86-K*2AV;VED*BP at 96YU;2!!5E],3T=?3$5614PL(&-O
M;G-T(&-H87(J+"!V85]L:7-T*2 ](&%V7VQO9U]D969A=6QT7V-A;&QB86-K
M.PH@(V5L<V4*+79O:60@*"IA=E]V;&]G*2AV;VED*BP@:6YT+"!C;VYS="!C
M:&%R*BP@=F%?;&ES="D@/2!A=E]L;V=?9&5F875L=%]C86QL8F%C:SL**W9O
M:60@*"IA=E]V;&]G*2AV;VED*BP at 96YU;2!!5E],3T=?3$5614PL(&-O;G-T
M(&-H87(J+"!V85]L:7-T*2 ](&%V7VQO9U]D969A=6QT7V-A;&QB86-K.PH@
M(V5N9&EF"B *+79O:60 at 879?;&]G*'9O:60J(&%V8VPL(&EN="!L979E;"P@
M8V]N<W0 at 8VAA<B J9FUT+" N+BXI"BMV;VED(&%V7VQO9RAV;VED*B!A=F-L
M+"!E;G5M($%67TQ/1U],159%3"!L979E;"P at 8V]N<W0 at 8VAA<B J9FUT+" N
M+BXI"B!["B @(" @=F%?;&ES="!V;#L*(" @("!V85]S=&%R="AV;"P at 9FUT
M*3L*0$ @+38P+#(R("LX,BPR,B! 0 T*('T*( H@(VEF($Q)0D%6551)3%]6
M15)324].7TE.5" \("@U,#P\,38I"BUV;VED(&%V7W9L;V<H=F]I9"H at 879C
M;"P@:6YT(&QE=F5L+"!C;VYS="!C:&%R("IF;70L('9A7VQI<W0@=FPI"BMV
M;VED(&%V7W9L;V<H=F]I9"H at 879C;"P at 96YU;2!!5E],3T=?3$5614P@;&5V
M96PL(&-O;G-T(&-H87(@*F9M="P@=F%?;&ES="!V;"D*('L*(" @("!A=E]L
M;V=?8V%L;&)A8VLH879C;"P@;&5V96PL(&9M="P@=FPI.PH@?0H@"BUI;G0@
M879?;&]G7V=E=%]L979E;"AV;VED*0HK96YU;2!!5E],3T=?3$5614P at 879?
M;&]G7V=E=%]L979E;"AV;VED*0H@>PH@(" @(')E='5R;B!A=E]L;V=?;&5V
M96P["B!]"B *+79O:60 at 879?;&]G7W-E=%]L979E;"AI;G0@;&5V96PI"BMV
M;VED(&%V7VQO9U]S971?;&5V96PH96YU;2!!5E],3T=?3$5614P@;&5V96PI
M"B!["B @(" @879?;&]G7VQE=F5L(#T@;&5V96P["B!]"B *+79O:60 at 879?
M;&]G7W-E=%]C86QL8F%C:RAV;VED("@J8V%L;&)A8VLI*'9O:60J+"!I;G0L
M(&-O;G-T(&-H87(J+"!V85]L:7-T*2D**W9O:60 at 879?;&]G7W-E=%]C86QL
M8F%C:RAV;VED("@J8V%L;&)A8VLI*'9O:60J+"!E;G5M($%67TQ/1U],159%
M3"P at 8V]N<W0 at 8VAA<BHL('9A7VQI<W0I*0H@>PH@(" @(&%V7VQO9U]C86QL
M8F%C:R ](&-A;&QB86-K.PH@?0I);F1E>#H@;&]G+F at -"CT]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T-"BTM+2!L;V<N: DH<F5V:7-I;VX at -C8X,2D-"BLK*R!L
M;V<N: DH=V]R:VEN9R!C;W!Y*0T*0$ @+3,X+#(U("LS."PR."! 0 T*( H@
M+RH at 879?;&]G($%022 J+PH@"BTC9&5F:6YE($%67TQ/1U]154E%5" M,0HM
M(V1E9FEN92!!5E],3T=?15)23U(@, HM(V1E9FEN92!!5E],3T=?24Y&3R Q
M"BTC9&5F:6YE($%67TQ/1U]$14)51R R"BME;G5M($%67TQ/1U],159%3"![
M"BL@(" @059?3$]'7U%52454(#T@("TQ+ HK(" @($%67TQ/1U]%4E)/4B @
M/2 P+ HK(" @($%67TQ/1U])3D9/(#T@,2P**R @("!!5E],3T=?1$5"54<@
M/2 R"BM].PHK"B!E>'1E<FX@:6YT(&%V7VQO9U]L979E;#L*( H@(VEF9&5F
M(%]?1TY50U]?"BUE>'1E<FX@=F]I9"!A=E]L;V<H=F]I9"HL(&EN="!L979E
M;"P at 8V]N<W0 at 8VAA<B J9FUT+" N+BXI(%]?871T<FEB=71E7U\@*"A?7V9O
M<FUA=%]?("A?7W!R:6YT9E]?+" S+" T*2DI.PHK97AT97)N('9O:60 at 879?
M;&]G*'9O:60J+"!E;G5M($%67TQ/1U],159%3"!L979E;"P at 8V]N<W0 at 8VAA
M<B J9FUT+" N+BXI(%]?871T<FEB=71E7U\@*"A?7V9O<FUA=%]?("A?7W!R
M:6YT9E]?+" S+" T*2DI.PH@(V5L<V4*+65X=&5R;B!V;VED(&%V7VQO9RAV
M;VED*BP@:6YT(&QE=F5L+"!C;VYS="!C:&%R("IF;70L("XN+BD["BME>'1E
M<FX@=F]I9"!A=E]L;V<H=F]I9"HL(&5N=6T at 059?3$]'7TQ%5D5,(&QE=F5L
M+"!C;VYS="!C:&%R("IF;70L("XN+BD["B C96YD:68*( H@(VEF($Q)0D%6
M551)3%]615)324].7TE.5" \("@U,#P\,38I"BUE>'1E<FX@=F]I9"!A=E]V
M;&]G*'9O:60J+"!I;G0@;&5V96PL(&-O;G-T(&-H87(@*F9M="P@=F%?;&ES
M="D["BUE>'1E<FX@:6YT(&%V7VQO9U]G971?;&5V96PH=F]I9"D["BUE>'1E
M<FX@=F]I9"!A=E]L;V=?<V5T7VQE=F5L*&EN="D["BUE>'1E<FX@=F]I9"!A
M=E]L;V=?<V5T7V-A;&QB86-K*'9O:60@*"HI*'9O:60J+"!I;G0L(&-O;G-T
M(&-H87(J+"!V85]L:7-T*2D["BME>'1E<FX@=F]I9"!A=E]V;&]G*'9O:60J
M+"!E;G5M($%67TQ/1U],159%3"!L979E;"P at 8V]N<W0 at 8VAA<B J9FUT+"!V
M85]L:7-T*3L**V5X=&5R;B!E;G5M($%67TQ/1U],159%3"!A=E]L;V=?9V5T
M7VQE=F5L*'9O:60I.PHK97AT97)N('9O:60 at 879?;&]G7W-E=%]L979E;"AE
M;G5M($%67TQ/1U],159%3"D["BME>'1E<FX@=F]I9"!A=E]L;V=?<V5T7V-A
M;&QB86-K*'9O:60@*"HI*'9O:60J+"!E;G5M($%67TQ/1U],159%3"P at 8V]N
M<W0 at 8VAA<BHL('9A7VQI<W0I*3L*("-E;'-E"BUE>'1E<FX@=F]I9" H*F%V
M7W9L;V<I*'9O:60J+"!I;G0L(&-O;G-T(&-H87(J+"!V85]L:7-T*3L**V5X
M=&5R;B!V;VED("@J879?=FQO9RDH=F]I9"HL(&5N=6T at 059?3$]'7TQ%5D5,
M+"!C;VYS="!C:&%R*BP@=F%?;&ES="D["B C96YD:68*( H@(V5N9&EF("\J
*($Q/1U](("HO"@``
`
end
More information about the ffmpeg-devel
mailing list