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

Michael Niedermayer michaelni at gmx.at
Wed Apr 30 02:33:43 CEST 2014


On Tue, Apr 29, 2014 at 02:22:49PM -0700, hjiodjf 97xgw46 wrote:
> On Sat, Apr 26, 2014 at 10:43 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Thu, Apr 24, 2014 at 03:08:38PM -0700, hjiodjf 97xgw46 wrote:
> > [...]
> >> @@ -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
> 
> An OPT_BOOL would let me set a flag somewhere, but something still
> needs to read the flag and pass it to av_log_set_flags. I couldn't
> find a good common place in the code to do that.

parse_loglevel() might work


> 
> >> 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
> >
> > [...]
> 
> For intermediate log levels, should I print the level with the
> next-lowest severity?

i dont know what is the best solution, just wanted to point the
problem out

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- 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/20140430/c4d7a939/attachment.asc>


More information about the ffmpeg-devel mailing list