[FFmpeg-devel] [PATCH] Add log severity level to default log formatting

Michael Niedermayer michaelni at gmx.at
Thu Apr 24 23:18:26 CEST 2014


On Thu, Apr 24, 2014 at 10:31:00AM -0700, hjiodjf 97xgw46 wrote:
> On Sat, Mar 29, 2014 at 5:07 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Thu, Feb 27, 2014 at 03:59:11PM -0800, hjiodjf 97xgw46 wrote:
> >> On Tue, Feb 18, 2014 at 3:14 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> >> > Does it add these messages unconditionally?
> >> > Please add an option that is disabled by default.
> >> >
> >> > Carl Eugen
> >>
> >> Here is a patch against git HEAD. It does add these messages
> >> unconditionally. I am not opposed to making it optional, but I don't
> >> see where to add this option. av_log_format_line is part of the public
> >> API and its signature is:
> >>
> >> void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
> >>                         char *line, int line_size, int *print_prefix)
> >
> > you can add a flag similar to the existing
> >
> > #define AV_LOG_SKIP_REPEATED 1
> >
> 
> I've taken michaelni's advice and implemented an AV_LOG flag and
> corresponding CLI option for this feature. I hope the latest
> incarnation of this patch can be reviewed, and more importantly, a
> decision made on if this feature is wanted.

>  cmdutils.c             |   16 +++++++++++++++-
>  cmdutils.h             |    2 ++
>  cmdutils_common_opts.h |    1 +
>  libavutil/log.c        |   48 +++++++++++++++++++++++++++++++++++++++---------
>  libavutil/log.h        |    9 +++++++++
>  5 files changed, 66 insertions(+), 10 deletions(-)
> e1e8f5ae3dbea74caff52f8c391369407f4a452f  0001-Add-AV_LOG_PRINT_LEVEL-flag-to-include-log-severity-.patch
> From 9e1cfef64832a205616d82302410f1c3474a2978 Mon Sep 17 00:00:00 2001
> From: tue46wsdgxfjrt <jfbvxt at gmail.com>
> Date: Thu, 27 Feb 2014 16:36:09 -0800
> Subject: [PATCH 1/2] Add AV_LOG_PRINT_LEVEL flag to include log severity in
>  default log formatting.
> 
> ---
>  cmdutils.c             | 16 +++++++++++++++-
>  cmdutils.h             |  2 ++
>  cmdutils_common_opts.h |  1 +
>  libavutil/log.c        | 48 +++++++++++++++++++++++++++++++++++++++---------
>  libavutil/log.h        |  9 +++++++++
>  5 files changed, 66 insertions(+), 10 deletions(-)
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index ebbbe7f..691836c 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -67,6 +67,7 @@ AVDictionary *format_opts, *codec_opts, *resample_opts;
>  
>  static FILE *report_file;
>  int hide_banner = 0;
> +int print_level = 0;
>  
>  void init_opts(void)
>  {
> @@ -834,10 +835,17 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
>      };
>      char *tail;
>      int level;
> +    int flags;
>      int i;
>  
> +    flags = av_log_get_flags();
>      tail = strstr(arg, "repeat");
> -    av_log_set_flags(tail ? 0 : AV_LOG_SKIP_REPEATED);
> +    if (tail)
> +        flags &= ~AV_LOG_SKIP_REPEATED;
> +    else
> +        flags |= AV_LOG_SKIP_REPEATED;
> +
> +    av_log_set_flags(flags);
>      if (tail == arg)
>          arg += 6 + (arg[6]=='+');
>      if(tail && !*arg)
> @@ -958,6 +966,12 @@ int opt_report(const char *opt)
>      return init_report(NULL);
>  }
>  
> +int opt_print_level(const char *opt)
> +{
> +    av_log_set_flags(av_log_get_flags() | AV_LOG_PRINT_LEVEL);
> +    return 0;
> +}
> +
>  int opt_max_alloc(void *optctx, const char *opt, const char *arg)
>  {
>      char *tail;
> diff --git a/cmdutils.h b/cmdutils.h
> index 2b9a825..be855d1 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -95,6 +95,8 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg);
>  
>  int opt_report(const char *opt);
>  
> +int opt_print_level(const char *opt);
> +
>  int opt_max_alloc(void *optctx, const char *opt, const char *arg);
>  
>  int opt_codec_debug(void *optctx, const char *opt, const char *arg);

> diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
> index 190dba6..4dde4fc 100644
> --- a/cmdutils_common_opts.h
> +++ b/cmdutils_common_opts.h
> @@ -22,6 +22,7 @@
>      { "max_alloc"  , HAS_ARG,  {.func_arg = opt_max_alloc},     "set maximum size of a single allocated block", "bytes" },
>      { "cpuflags"   , HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" },
>      { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner},     "do not show program banner", "hide_banner" },
> +    { "print_level", 0,        {(void*)opt_print_level},        "include log level in console output"},

this will fail with av_log() that are run before the main command line
parsing.
the log level is special cased so its parsed earlier

also it seems this patch breaks the output
there seem alot more "Last message repeated" messages than
actually repeated messages

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140424/b244bd06/attachment.asc>


More information about the ffmpeg-devel mailing list