[vlc-devel] [PATCH 0/2] Libvlc formatted log callback

Jeremy Vignelles jeremy.vignelles at dev3i.fr
Fri May 17 13:36:29 CEST 2019


> Le 17 mai 2019 à 13:20, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
> 
> 
> On 2019-05-17 10:04, Jérémy VIGNELLES wrote:
> > Hi,
> > 
> > In libvlc, there is currently a `libvlc_log_set` function, that can register
> > log callback in a vprintf style, that is, with a `va_list` argument.
> > 
> > This is nice when you are trying to call from C, but when using other languages
> > like C# or Java, va_list is impossible to get right, and even if it did,
> > those languages do not provide ways to format that kind of stuff.
> > 
> > The best attempt so far seems to write an external native project to do that,
> > like this one : https://github.com/jeremyVignelles/libvlcLogInterop, but it has
> > a major drawback: it needs to be compiled for every host triplet that vlc supports,
> > which is a lot of work (if even possible), and requires the correct v*printf to be
> > available on the standard library.
> > 
> > I'm attempting here another approach : Modify libvlc v4 to include a preformatted
> > version of libvlc_log_set. The caller is now able to get log message as a single string,
> > and can filter by log level before formatting.
> 
> That sounds like a good idea.
> 
> We might also remove the old API (or mark it deprecated) because there's 
> not much sense in having both. And a va_list without parsing it to 
> create the string is pointless anyway.

We can indeed obsolete the old one and keep this patch as-is (or make the context auto-destroyed as Romain suggested, but what do you think of "reversing things"?

I mean make the new API the one to use (edit libvlc_instance_t.log to contain a preformatted callback and a min log level instead of a libvlc_log_cb), and make a deprecated libvlc_log_set that will call the new API under the hood? That would keep compat with older code/bindings (the va_list would always be empty).

> > The new API requires a context to be created and destroyed, in order to keep compatibility with
> > libvlc_log_set.
> > 
> > I thought about modifying the libvlc_instance_t.log structure and put my context there,
> > but I was unsure about how that would interact with the existing things
> > 
> > Comments welcome :)
> > 
> > Jérémy VIGNELLES (2):
> >  libvlc: added a formatted log callback
> >  test: libvlc: Added a formatted log callback test
> > 
> >  include/vlc/libvlc.h | 64 ++++++++++++++++++++++++++++++++++++++++++++
> >  lib/libvlc.sym | 3 +++
> >  lib/log.c | 55 +++++++++++++++++++++++++++++++++++++
> >  test/libvlc/core.c | 27 +++++++++++++++++++
> >  4 files changed, 149 insertions(+)
> > 
> > -- 
> > 2.21.0.windows.1
> > 
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list