[vlc-devel] [PATCH 0/2] Libvlc formatted log callback
Romain Vimont
rom1v at videolabs.io
Fri May 17 11:23:44 CEST 2019
On Fri, May 17, 2019 at 10:04:59AM +0200, 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.
I agree that we should avoid va_list in callbacks :)
> 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.
(not counter-arguments, just comments)
I don't know C#, but in Java you will need a JNI layer in C, so it can
be handled here.
BTW, in pure Java, you can format using String.format():
String s = String.format("%s %d", "hello", 42).
> 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.
>
> 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
More information about the vlc-devel
mailing list