[vlc-devel] [vlc-commits] logger: support android

Hugo Beauzée-Luyssen beauze.h at gmail.com
Mon Jan 23 16:55:34 CET 2012


On Mon, Jan 23, 2012 at 4:53 PM, Hugo Beauzée-Luyssen
<beauze.h at gmail.com> wrote:
> On Mon, Jan 23, 2012 at 4:47 PM, Rafaël Carré <git at videolan.org> wrote:
>> vlc/vlc-1.2 | branch: master | Rafaël Carré <funman at videolan.org> | Fri Jan 20 18:35:23 2012 -0500| [b021b4e45c9dbe9ca8885cb6966a9b48f787c731] | committer: Jean-Baptiste Kempf
>>
>> logger: support android
>> (cherry picked from commit a43414d06f78d2a6e7d5c87ae612c32b69bc6d19)
>>
>> Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
>>
>>> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=b021b4e45c9dbe9ca8885cb6966a9b48f787c731
>> ---
>>
>>  modules/misc/Modules.am |    5 ++++
>>  modules/misc/logger.c   |   48 +++++++++++++++++++++++++++++++++++++++++++++-
>>  2 files changed, 51 insertions(+), 2 deletions(-)
>>
>> diff --git a/modules/misc/Modules.am b/modules/misc/Modules.am
>> index 4697942..37d4ba2 100644
>> --- a/modules/misc/Modules.am
>> +++ b/modules/misc/Modules.am
>> @@ -44,6 +44,11 @@ libmce_plugin_la_DEPENDENCIES =
>>  EXTRA_LTLIBRARIES += libmce_plugin.la
>>  libvlc_LTLIBRARIES += $(LTLIBmce)
>>
>> +liblogger_plugin_la_LIBADD = $(AM_LIBADD)
>> +if HAVE_ANDROID
>> +liblogger_plugin_la_LIBADD += -llog
>> +endif
>> +
>>  libvlc_LTLIBRARIES += \
>>        libaudioscrobbler_plugin.la \
>>        liblogger_plugin.la
>> diff --git a/modules/misc/logger.c b/modules/misc/logger.c
>> index 7f7ed6c..9927357 100644
>> --- a/modules/misc/logger.c
>> +++ b/modules/misc/logger.c
>> @@ -38,6 +38,10 @@
>>  #include <stdarg.h>
>>  #include <assert.h>
>>
>> +#ifdef __ANDROID__
>> +# include <android/log.h>
>> +#endif
>> +
>>  #define MODE_TEXT 0
>>  #define MODE_HTML 1
>>  #define MODE_SYSLOG 2
>> @@ -95,6 +99,9 @@ static void HtmlPrint(void *, int, const msg_item_t *, const char *, va_list);
>>  static void SyslogPrint(void *, int, const msg_item_t *, const char *,
>>                         va_list);
>>  #endif
>> +#ifdef __ANDROID__
>> +static void AndroidPrint(void *, int, const msg_item_t *, const char *, va_list);
>> +#endif
>>
>>  /*****************************************************************************
>>  * Module descriptor
>> @@ -103,11 +110,17 @@ static const char *const mode_list[] = { "text", "html"
>>  #ifdef HAVE_SYSLOG_H
>>  ,"syslog"
>>  #endif
>> +#ifdef __ANDROID__
>> +,"android"
>> +#endif
>>  };
>>  static const char *const mode_list_text[] = { N_("Text"), "HTML"
>>  #ifdef HAVE_SYSLOG_H
>>  , "syslog"
>>  #endif
>> +#ifdef __ANDROID__
>> +,"android"
>> +#endif
>>  };
>>
>>  #define LOGMODE_TEXT N_("Log format")
>> @@ -117,8 +130,9 @@ static const char *const mode_list_text[] = { N_("Text"), "HTML"
>>  #else
>>
>>  #define LOGMODE_LONGTEXT N_("Specify the log format. Available choices are " \
>> -  "\"text\" (default), \"html\", and \"syslog\" (special mode to send to " \
>> -  "syslog instead of file.")
>> +  "\"text\" (default), \"html\", \"syslog\" (special mode to send to " \
>> +  "syslog instead of file), and \"android\" (special mode to send to " \
>> +  "android logging facility).")
>>
>>  #define SYSLOG_FACILITY_TEXT N_("Syslog facility")
>>  #define SYSLOG_FACILITY_LONGTEXT N_("Select the syslog facility where logs " \
>> @@ -212,6 +226,10 @@ static int Open( vlc_object_t *p_this )
>>         else if( !strcmp( mode, "syslog" ) )
>>             cb = SyslogPrint;
>>  #endif
>> +#ifdef __ANDROID__
>> +        else if( !strcmp( mode, "android" ) )
>> +            cb = AndroidPrint;
>> +#endif
>>         else if( strcmp( mode, "text" ) )
>>             msg_Warn( p_intf, "invalid log mode `%s', using `text'", mode );
>>         free( mode );
>> @@ -254,6 +272,9 @@ static int Open( vlc_object_t *p_this )
>>     }
>>     else
>>  #endif
>> +#ifdef __ANDROID__
>> +    if( cb != AndroidPrint )
>> +#endif
>>     {
>>         char *psz_file = var_InheritString( p_intf, "logfile" );
>>         if( !psz_file )
>> @@ -338,6 +359,29 @@ static const char ppsz_type[4][9] = {
>>     " debug",
>>  };
>>
>> +#ifdef __ANDROID__
>> +static const android_LogPriority prioritytype[4] = {
>> +    ANDROID_LOG_INFO,
>> +    ANDROID_LOG_ERROR,
>> +    ANDROID_LOG_WARN,
>> +    ANDROID_LOG_DEBUG
>> +};
>> +
>> +static void AndroidPrint( void *opaque, int type, const msg_item_t *item,
>> +                       const char *fmt, va_list ap )
>> +{
>> +    (void)item;
>> +    intf_thread_t *p_intf = opaque;
>> +
>> +    if( IgnoreMessage( p_intf, type ) )
>> +        return;
>> +
>> +    int canc = vlc_savecancel();
>> +    __android_log_vprint(prioritytype[type], "vlc", fmt, ap);
>> +    vlc_restorecancel( canc );
>> +}
>> +#endif
>> +
>>  static void TextPrint( void *opaque, int type, const msg_item_t *item,
>>                        const char *fmt, va_list ap )
>>  {
>>
>
> Here it is, fixed and split.
>
> Regards,
>

Oops...
Let's pretend this never happened :)

Regards,


-- 
Hugo Beauzée-Luyssen



More information about the vlc-devel mailing list