From: Mike Brady Date: Sat, 10 Mar 2018 18:54:07 +0000 (+0000) Subject: Tidy up the diagnostic commands and make them all work. Add a few example. X-Git-Tag: 3.2d29~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cfd5676c42b6ab59bcbca4a9b0dbb44b665b936;p=thirdparty%2Fshairport-sync.git Tidy up the diagnostic commands and make them all work. Add a few example. --- diff --git a/dbus-diagnostics.c b/dbus-diagnostics.c index 8a1cbc17..89f2f8f3 100644 --- a/dbus-diagnostics.c +++ b/dbus-diagnostics.c @@ -17,10 +17,36 @@ 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 index 00000000..7e7a3c9d --- /dev/null +++ b/documents/sample dbus commands @@ -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 diff --git a/org.gnome.ShairportSync.Diagnostics.xml b/org.gnome.ShairportSync.Diagnostics.xml index 4a85b6e1..fed5c4b9 100644 --- a/org.gnome.ShairportSync.Diagnostics.xml +++ b/org.gnome.ShairportSync.Diagnostics.xml @@ -1,10 +1,9 @@ - - - - - + + + +