[gvfs] mtp: Allow toggling libmtp debug output
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] mtp: Allow toggling libmtp debug output
- Date: Wed, 29 Nov 2017 09:24:15 +0000 (UTC)
commit eb976998228321df52454930606aaac3a9e6e52c
Author: Ondrej Holy <oholy redhat com>
Date: Wed Nov 29 09:55:20 2017 +0100
mtp: Allow toggling libmtp debug output
libmtp provides LIBMTP_DEBUG environment variable already, but with
binary flags. Let's introduce GVFS_MTP_DEBUG environment variable as
has other backends to toggle libmtp debug output with string values.
Possible values are "all", "data", "usb", or "ptp".
daemon/gvfsbackendmtp.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index a606ec2..556a197 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -378,6 +378,7 @@ g_vfs_backend_mtp_init (GVfsBackendMtp *backend)
{
g_debug ("(I) g_vfs_backend_mtp_init\n");
GMountSpec *mount_spec;
+ const char *debug;
g_mutex_init (&backend->mutex);
g_vfs_backend_set_display_name (G_VFS_BACKEND (backend), "mtp");
@@ -394,6 +395,22 @@ g_vfs_backend_mtp_init (GVfsBackendMtp *backend)
backend, 1, FALSE, NULL);
#endif
+ debug = g_getenv ("GVFS_MTP_DEBUG");
+ if (debug != NULL) {
+ int level;
+
+ if (g_ascii_strcasecmp ("ptp", debug) == 0)
+ level = LIBMTP_DEBUG_PTP;
+ else if (g_ascii_strcasecmp ("usb", debug) == 0)
+ level = LIBMTP_DEBUG_USB | LIBMTP_DEBUG_PTP;
+ else if (g_ascii_strcasecmp ("data", debug) == 0)
+ level = LIBMTP_DEBUG_DATA | LIBMTP_DEBUG_USB | LIBMTP_DEBUG_PTP;
+ else /* "all" */
+ level = LIBMTP_DEBUG_ALL;
+
+ LIBMTP_Set_Debug (level);
+ }
+
g_debug ("(I) g_vfs_backend_mtp_init done.\n");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]