[FFmpeg-devel] [PATCH 1/2] avutil/log: Add av_log_once() for printing a message just once per instance

Michael Niedermayer michael at niedermayer.cc
Fri Jan 24 14:04:08 EET 2020


On Tue, Jan 21, 2020 at 07:44:46PM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-01-21 15:43:48)
> > On Tue, Jan 21, 2020 at 12:24:50PM +0100, Anton Khirnov wrote:
> > > Quoting Michael Niedermayer (2020-01-16 17:51:28)
> > > > Compared to ad-hoc if(printed) ... code this allows the user to disable
> > > > it with a flag and see all repeated messages, it is also simpler
> > > 
> > > That flag is global state - it should be deprecated and removed, not
> > > embedded further into the API.
> > 
> > When the flag is replaced by a non global solution every of its uses
> > would be replaced too.
> > 
> > Until such a non global API exists, this is the only way the user can
> > indicate her choice of which log messages to print.
> > Code should honor the existing API and user preferrance.
> 
> The problem is that right now, flags is only used by the default log
> callback. The behaviour of the default log callback is not specified by
> the API, so it can be changed later without much trouble. With this
> patch, the function of flags is hardcoded into the API, making its
> future removal significantly harder.

I dont really see this concern. Because if you disable the flag "today"
you break the API as it is documented, the flag is documented to
affect the message repeation.
With this patch, disabling it still breaks a bunch of message repeating
behavior, so to me this looks like its basically the same.

But what do you suggest ?

We could send all the repeated _once() messages to the callback and leave it
to the callback to drop them. Just needs a way to tag them as repeats

We could move the (no)repeat flag to each context but this feels unwieldy
and feels like it solves a problem noone had. Because noone ever asked
AFAIR that they wanted to change repeating behavior on a per context base.
This is probably mostly used by developers wanting to check for "all"
messages. Or users produding bug reports which also would ideally have
no dropped messages.

I can also just drop the use of the flag entirely from the patch and just
leave this as a unconditional _once() log. It feels a bit like a missing
feature though because as a devleoper for debuging a simple switch to
see all repeats seems usefull.

Thanks


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200124/08ef76d8/attachment.sig>


More information about the ffmpeg-devel mailing list