[vlmc-devel] [PATCH] MLTBackend: Add MLT service info in logHandler

yikei lu luyikei.qmltu at gmail.com
Sat Jul 30 07:36:25 CEST 2016


2016-07-30 2:16 GMT+09:00 Pawel Golinski <golpaw1 at gmail.com>:
> ---
>  src/Backend/MLT/MLTBackend.cpp | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/src/Backend/MLT/MLTBackend.cpp b/src/Backend/MLT/MLTBackend.cpp
> index 3d39930..af952f1 100644
> --- a/src/Backend/MLT/MLTBackend.cpp
> +++ b/src/Backend/MLT/MLTBackend.cpp
> @@ -28,10 +28,12 @@
>  #include <mlt++/MltRepository.h>
>
>  #include <mlt/framework/mlt_log.h>
> +#include <mlt/framework/mlt_service.h>
>
>  #include "MLTFilter.h"
>
>  #include <mutex>
> +#include <sstream>
>
>  #include "Tools/VlmcDebug.h"
>  #include "vlmc.h"
> @@ -101,8 +103,28 @@ void
>  MLTBackend::setLogHandler( IBackend::LogHandler logHandler )
>  {
>      staticLogHandler = logHandler;
> -    mlt_log_set_callback( []( void*, int level, const char* format, va_list vl )
> +    mlt_log_set_callback( []( void* ptr, int level, const char* format, va_list vl )
>      {
> +        std::string msg_str;
> +
> +        Mlt::Properties properties( mlt_service_properties( ( mlt_service )ptr ) );

Sorry, it was my fault but I think you should do just like
Mlt::Service service( ( mlt_service )ptr )

Though thanks for your work!

Regards,

> +
> +        if ( properties.is_valid() )
> +        {
> +            const char *mlt_type = properties.get( "mlt_type" );
> +            const char *mlt_service = properties.get( "mlt_service" );
> +            std::ostringstream os;
> +
> +            if ( mlt_service && mlt_type )
> +                os << "[" << mlt_type << " " << mlt_service << "] ";
> +            else if ( mlt_type )
> +            {
> +                os << "[" << mlt_type << " " << ptr << "] ";
> +            }
> +
> +            msg_str = os.str();
> +        }
> +
>          char* buffer = nullptr;
>
>          auto lvl = IBackend::None;
> @@ -118,7 +140,12 @@ MLTBackend::setLogHandler( IBackend::LogHandler logHandler )
>          if ( vasprintf( &buffer, format, vl ) < 0 )
>              return;
>
> -        staticLogHandler( lvl, buffer );
> +        if ( buffer )
> +            msg_str += buffer;
> +
> +        if ( !msg_str.empty() )
> +            staticLogHandler( lvl, msg_str.c_str() );
> +
>          free( buffer );
>      } );
>  }
> --
> 2.7.4 (Apple Git-66)
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel


More information about the Vlmc-devel mailing list