[vlc-devel] [PATCH] messages.c: added logging via OutputDebugString under windows.

Rémi Denis-Courmont remi at remlab.net
Wed Dec 21 08:01:59 CET 2011


On Tue, 20 Dec 2011 22:09:33 -0500, Sergey Radionov <RSATom at gmail.com>
wrote:
> Signed-off-by: Rafaël Carré <funman at videolan.org>
> ---
>  src/misc/messages.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/src/misc/messages.c b/src/misc/messages.c
> index 8c0b723..e6b6aeb 100644
> --- a/src/misc/messages.c
> +++ b/src/misc/messages.c
> @@ -132,6 +132,10 @@ void vlc_Log (vlc_object_t *obj, int type, const
char
> *module,
>  static void PrintColorMsg (void *, int, const msg_item_t *,
>                             const char *, va_list);
>  static void PrintMsg (void *, int, const msg_item_t *, const char *,
>  va_list);
> +#ifdef WIN32
> +static void Win32DebugOutputMsg (void *, int , const msg_item_t *,
> +                                 const char *, va_list);
> +#endif
>  
>  /**
>   * Emit a log message. This function is the variable argument list
>   equivalent
> @@ -230,6 +234,13 @@ void vlc_vaLog (vlc_object_t *obj, int type, const
> char *module,
>          PrintMsg (&priv->i_verbose, type, &msg, format, ap);
>      va_end (ap);
>  
> +#ifdef WIN32
> +    va_list dol;
> +    va_copy (dol, args);
> +    Win32DebugOutputMsg (0, type, &msg, format, dol);

Please don't use 0 as a pointer.

> +    va_end (dol);
> +#endif
> +
>      vlc_rwlock_rdlock (&msg_lock);
>      for (msg_subscription_t *sub = msg_head; sub != NULL; sub =
sub->next)
>      {
> @@ -303,3 +314,30 @@ static void PrintMsg (void *d, int type, const
> msg_item_t *p_item,
>      funlockfile (stream);
>      vlc_restorecancel (canc);
>  }
> +
> +#ifdef WIN32
> +static void Win32DebugOutputMsg (void* d, int type, const msg_item_t
> *p_item,
> +                                 const char *format, va_list dol)
> +{
> +    const signed char *pverbose = d;
> +    if (*pverbose < 0 || *pverbose < (type - VLC_MSG_ERR))
> +        return;

Did you actually test this? It looks like *NULL to me.

> +
> +    size_t fmt_len = strlen(format);
> +    char *fmt_cr = malloc(fmt_len + 1 + 1);
> +    if (!fmt_cr)
> +        return;
> +
> +    strcpy(fmt_cr, format);
> +    fmt_cr[fmt_len] = '\n';
> +    fmt_cr[fmt_len + 1] = '\0';
> +    char *msg;
> +    if (vasprintf(&msg, fmt_cr, dol))
> +        msg = NULL;
> +
> +    if (msg)
> +        OutputDebugString(msg);
> +    free(fmt_cr);
> +    free(msg);
> +}
> +#endif

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list