]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Tidy up the diagnostic commands and make them all work. Add a few example.
authorMike Brady <mikebrady@eircom.net>
Sat, 10 Mar 2018 18:54:07 +0000 (18:54 +0000)
committerMike Brady <mikebrady@eircom.net>
Sat, 10 Mar 2018 18:54:07 +0000 (18:54 +0000)
dbus-diagnostics.c
documents/sample dbus commands [new file with mode: 0644]
org.gnome.ShairportSync.Diagnostics.xml

index 8a1cbc17d48438a3dc289f54cbda0a23c69aa0ef..89f2f8f30332d16a1e96a4baab713d4c95963712 100644 (file)
 
 ShairportSyncDiagnostics *shairportSyncDiagnosticsSkeleton;
 
-gboolean notify_include_statistics_in_log_callback(ShairportSyncDiagnostics *skeleton,
+gboolean notify_elapsed_time_callback(ShairportSyncDiagnostics *skeleton,
                                                 __attribute__((unused)) gpointer user_data) {
-  debug(1, "\"notify_include_statistics_in_log_callback\" called.");
-  if (shairport_sync_diagnostics_get_include_statistics_in_log(skeleton)) {
+  // debug(1, "\"notify_elapsed_time_callback\" called.");
+  if (shairport_sync_diagnostics_get_elapsed_time(skeleton)) {
+    debug(1, ">> start including elapsed time in logs");
+    config.debugger_show_elapsed_time = 1;
+  } else {
+    debug(1, ">> stop including elapsed time in logs");
+    config.debugger_show_elapsed_time = 0;
+  }
+  return TRUE;
+}
+
+gboolean notify_delta_time_callback(ShairportSyncDiagnostics *skeleton,
+                                                __attribute__((unused)) gpointer user_data) {
+  // debug(1, "\"notify_delta_time_callback\" called.");
+  if (shairport_sync_diagnostics_get_delta_time(skeleton)) {
+    debug(1, ">> start including delta time in logs");
+    config.debugger_show_relative_time = 1;
+  } else {
+    debug(1, ">> stop including delta time in logs");
+    config.debugger_show_relative_time = 0;
+  }
+  return TRUE;
+}
+
+gboolean notify_statistics_callback(ShairportSyncDiagnostics *skeleton,
+                                                __attribute__((unused)) gpointer user_data) {
+  // debug(1, "\"notify_statistics_callback\" called.");
+  if (shairport_sync_diagnostics_get_statistics(skeleton)) {
     debug(1, ">> start logging statistics");
     config.statistics_requested = 1;
   } else {
@@ -30,14 +56,14 @@ gboolean notify_include_statistics_in_log_callback(ShairportSyncDiagnostics *ske
   return TRUE;
 }
 
-gboolean notify_log_verbosity_callback(ShairportSyncDiagnostics *skeleton,
+gboolean notify_verbosity_callback(ShairportSyncDiagnostics *skeleton,
                                             __attribute__((unused)) gpointer user_data) {
-  gint th = shairport_sync_diagnostics_get_log_verbosity(skeleton);
+  gint th = shairport_sync_diagnostics_get_verbosity(skeleton);
   if ((th >= 0) && (th <= 3)) {
-    debug(1, "Setting log verbosity to %d.", th);
+    debug(1, ">> set log verbosity to %d.", th);
     debuglev = th;
   } else {
-    debug(1, "Invalid log verbosity: %d. Ignored.", th);
+    debug(1, ">> invalid log verbosity: %d. Ignored.", th);
   }
   return TRUE;
 }
@@ -45,31 +71,51 @@ gboolean notify_log_verbosity_callback(ShairportSyncDiagnostics *skeleton,
 void dbus_diagnostics_on_dbus_name_acquired(GDBusConnection *connection,
                                   __attribute__((unused))  const gchar *name,
                                   __attribute__((unused)) gpointer user_data) {
-  debug(1,"dbus_diagnostics_on_dbus_name_acquired");
+  // debug(1,"dbus_diagnostics_on_dbus_name_acquired");
   shairportSyncDiagnosticsSkeleton = shairport_sync_diagnostics_skeleton_new();
   g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncDiagnosticsSkeleton), connection,
                                    "/org/gnome/ShairportSync/Diagnostics", NULL);
                                    
-  shairport_sync_diagnostics_set_log_verbosity(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton),
+  shairport_sync_diagnostics_set_verbosity(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton),
                                         debuglev);
                                         
-  debug(1,"Log verbosity is %d.",debuglev);
+  // debug(2,">> log verbosity is %d.",debuglev);
 
   if (config.statistics_requested == 0) {
-    shairport_sync_diagnostics_set_include_statistics_in_log(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
-    debug(1, "Statistics Logging is off");
+    shairport_sync_diagnostics_set_statistics(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
+    // debug(1, ">> statistics logging is off");
   } else {
-    shairport_sync_diagnostics_set_include_statistics_in_log(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
-    debug(1, "Statistics Logging is on");
+    shairport_sync_diagnostics_set_statistics(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
+    // debug(1, ">> statistics logging is on");
   }
   
-  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::log-verbosity",
-                   G_CALLBACK(notify_log_verbosity_callback), NULL);
+  if (config.debugger_show_elapsed_time == 0) {
+    shairport_sync_diagnostics_set_elapsed_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
+    // debug(1, ">> elapsed time is included in log entries");
+  } else {
+    shairport_sync_diagnostics_set_elapsed_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
+    // debug(1, ">> elapsed time is not included in log entries");
+  }
+
+  if (config.debugger_show_relative_time == 0) {
+    shairport_sync_diagnostics_set_delta_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
+    // debug(1, ">> delta time is included in log entries");
+  } else {
+    shairport_sync_diagnostics_set_delta_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
+    // debug(1, ">> delta time is not included in log entries");
+  }
+
+  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::verbosity",
+                   G_CALLBACK(notify_verbosity_callback), NULL);
 
+  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::statistics",
+                   G_CALLBACK(notify_statistics_callback), NULL);
 
-  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::include-statistics-in-log",
-                   G_CALLBACK(notify_include_statistics_in_log_callback), NULL);
+  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::elapsed-time",
+                   G_CALLBACK(notify_elapsed_time_callback), NULL);
 
+  g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::delta-time",
+                   G_CALLBACK(notify_delta_time_callback), NULL);
 
 }
 
diff --git a/documents/sample dbus commands b/documents/sample dbus commands
new file mode 100644 (file)
index 0000000..7e7a3c9
--- /dev/null
@@ -0,0 +1,10 @@
+# Get Log Verbosity
+dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync/Diagnostics org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync.Diagnostics string:Verbosity
+# Return Log Verbosity
+echo `dbus-send --print-reply=literal --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync/Diagnostics org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync.Diagnostics string:Verbosity`
+# Set Log Verbosity to 2
+dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync/Diagnostics org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync.Diagnostics string:Verbosity variant:int32:2
+# Get Statistics-Requested Status
+dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync/Diagnostics org.freedesktop.DBus.Properties.Get string:org.gnome.ShairportSync.Diagnostics string:Statistics
+# Set Statistics-Requested Status to true
+dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync/Diagnostics org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync.Diagnostics string:Statistics variant:boolean:true
index 4a85b6e193aba94aa93b2047151ac27cd34731da..fed5c4b93ececffb4e282d04c3147bc0b481f8f5 100644 (file)
@@ -1,10 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
   <interface name="org.gnome.ShairportSync.Diagnostics">
-    <property name="LogVerbosity" type="i" access="readwrite" />
-    <property name="IncludeStatisticsInLog" type="b" access="readwrite" />
-    <property name="IncludeElapsedTimeInLog" type="b" access="readwrite" />
-    <property name="IncludeDeltaTimeInLog" type="b" access="readwrite" />
-    <property name="DisableResendRequests" type="b" access="readwrite" />
+    <property name="Verbosity" type="i" access="readwrite" />
+    <property name="Statistics" type="b" access="readwrite" />
+    <property name="ElapsedTime" type="b" access="readwrite" />
+    <property name="DeltaTime" type="b" access="readwrite" />
   </interface>
 </node>