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

Michael Niedermayer michaelni at gmx.at
Sat Apr 26 19:43:42 CEST 2014


On Thu, Apr 24, 2014 at 03:08:38PM -0700, hjiodjf 97xgw46 wrote:
> On Thu, Apr 24, 2014 at 2:18 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Thu, Apr 24, 2014 at 10:31:00AM -0700, hjiodjf 97xgw46 wrote:
> >> 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
> 
> I forgot to update the code that stores the last printed line. I have
> attached a fixed patch that avoids the erroneous "Last message
> repeated" events and hooks into parse_loglevel to allow initialization
> before option parsing.

>  cmdutils.c             |   19 +++++++++++++++++-
>  cmdutils.h             |    2 +
>  cmdutils_common_opts.h |    1 
>  libavutil/log.c        |   50 +++++++++++++++++++++++++++++++++++++++----------
>  libavutil/log.h        |    9 ++++++++
>  5 files changed, 70 insertions(+), 11 deletions(-)
> c40bf508780456c1e6eb4c54b542a13431a55d36  0001-Add-AV_LOG_PRINT_LEVEL-flag-to-include-log-severity-.patch
> From 4ea25a07d6817ead75a503626a1e11da8580ffb7 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.

partly applied
see comments below


[...]
> @@ -958,6 +969,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;
> +}

this allows enabling but not disabling the feature



> +
>  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"},

why is this not OPT_BOOL? that should allow disabling as well


>  #if CONFIG_OPENCL
>      { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, "run benchmark on all OpenCL devices and show results" },
>      { "opencl_options", HAS_ARG, {.func_arg = opt_opencl},      "set OpenCL environment options" },
> diff --git a/libavutil/log.c b/libavutil/log.c
> index cf4d990..0a8220b 100644
> --- a/libavutil/log.c
> +++ b/libavutil/log.c
> @@ -212,13 +212,38 @@ static int get_category(void *ptr){
>      return avc->category + 16;
>  }
>  
> +static const char *get_level_str(int level)
> +{
> +    switch (level) {
> +    case AV_LOG_QUIET:
> +        return "quiet";
> +    case AV_LOG_DEBUG:
> +        return "debug";
> +    case AV_LOG_VERBOSE:
> +        return "verbose";
> +    case AV_LOG_INFO:
> +        return "info";
> +    case AV_LOG_WARNING:
> +        return "warning";
> +    case AV_LOG_ERROR:
> +        return "error";
> +    case AV_LOG_FATAL:
> +        return "fatal";
> +    case AV_LOG_PANIC:
> +        return "panic";
> +    default:
> +        return "";
> +    }
> +}

that probably is fine with most or all existing code but there are
intermediate log levels too

also APIChanges update is missing

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- 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/20140426/cf4f7f21/attachment.asc>


More information about the ffmpeg-devel mailing list