qt: actions_manager: compareRenderers -> getMatchingRenderer
[vlc.git] / modules / logger / android.c
bloba2207d4ef3cf0993e403eff32e8f9f914fe7b4f9
1 /*****************************************************************************
2 * android.c: Android logger using logcat
3 *****************************************************************************
4 * Copyright © 2015 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef __ANDROID__
22 #error __ANDROID__ not defined
23 #endif
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
29 #include <android/log.h>
31 #include <stdarg.h>
32 #include <stdio.h>
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
37 static const int ptr_width = 2 * /* hex digits */ sizeof (uintptr_t);
39 static void AndroidPrintMsg(void *opaque, int type, const vlc_log_t *p_item,
40 const char *format, va_list ap)
42 int prio;
43 char *format2;
44 int verbose = (intptr_t)opaque;
46 if (verbose < type)
47 return;
49 if (asprintf(&format2, "[%0*"PRIxPTR"/%lx] %s %s: %s",
50 ptr_width, p_item->i_object_id, p_item->tid, p_item->psz_module,
51 p_item->psz_object_type, format) < 0)
52 return;
53 switch (type) {
54 case VLC_MSG_INFO:
55 prio = ANDROID_LOG_INFO;
56 break;
57 case VLC_MSG_ERR:
58 prio = ANDROID_LOG_ERROR;
59 break;
60 case VLC_MSG_WARN:
61 prio = ANDROID_LOG_WARN;
62 break;
63 default:
64 case VLC_MSG_DBG:
65 prio = ANDROID_LOG_DEBUG;
67 __android_log_vprint(prio, "VLC", format2, ap);
68 free(format2);
71 static vlc_log_cb Open(vlc_object_t *obj, void **sysp)
73 int verbosity = var_InheritInteger(obj, "verbose");
75 if (verbosity < 0)
76 return NULL;
78 verbosity += VLC_MSG_ERR;
79 *sysp = (void *)(uintptr_t)verbosity;
81 return AndroidPrintMsg;
84 vlc_module_begin()
85 set_shortname(N_("Android log"))
86 set_description(N_("Android log using logcat"))
87 set_category(CAT_ADVANCED)
88 set_subcategory(SUBCAT_ADVANCED_MISC)
89 set_capability("logger", 30)
90 set_callbacks(Open, NULL)
91 vlc_module_end ()