projects/package-update-indicator
changeset 45:4a859595eabd
Add debug logging when periodic checks are inhibited
author | Guido Berhoerster <guido+pui@berhoerster.name> |
---|---|
date | Thu Nov 05 11:18:16 2020 +0100 (18 months ago) |
parents | 3da32a3ffe3c |
children | 8ed91c5e0116 |
files | pui-backend.c |
line diff
1.1 --- a/pui-backend.c Thu Oct 08 15:47:15 2020 +0200 1.2 +++ b/pui-backend.c Thu Nov 05 11:18:16 2020 +0100 1.3 @@ -251,14 +251,16 @@ 1.4 static void 1.5 check_inhibit(PuiBackend *self) 1.6 { 1.7 + gboolean is_offline; 1.8 + gboolean is_disallowed_mobile; 1.9 gboolean inhibited; 1.10 guint elapsed_time; 1.11 guint remaining_time; 1.12 1.13 - inhibited = ((self->network_state == PK_NETWORK_ENUM_OFFLINE) || 1.14 - (!self->use_mobile_connection && 1.15 - (self->network_state == PK_NETWORK_ENUM_MOBILE)) || 1.16 - self->is_battery_low); 1.17 + is_offline = self->network_state == PK_NETWORK_ENUM_OFFLINE; 1.18 + is_disallowed_mobile = !self->use_mobile_connection && 1.19 + (self->network_state == PK_NETWORK_ENUM_MOBILE); 1.20 + inhibited = is_offline || is_disallowed_mobile || self->is_battery_low; 1.21 if (self->inhibited == inhibited) { 1.22 return; 1.23 } 1.24 @@ -276,6 +278,17 @@ 1.25 g_cancellable_cancel(self->cancellable); 1.26 g_clear_object(&self->cancellable); 1.27 } 1.28 + 1.29 + if (is_offline) { 1.30 + g_debug("perioidic checks inhibited: network offline"); 1.31 + } 1.32 + if (is_disallowed_mobile) { 1.33 + g_debug("perioidic checks inhibited: use of mobile " 1.34 + "connection not allowed"); 1.35 + } 1.36 + if (self->is_battery_low) { 1.37 + g_debug("perioidic checks inhibited: low battery"); 1.38 + } 1.39 } else { 1.40 /* schedule periodic checks when no longer inhibited */ 1.41 elapsed_time = (g_get_monotonic_time() - self->last_check) / 1.42 @@ -290,6 +303,10 @@ 1.43 PUI_STARTUP_DELAY; 1.44 self->check_id = g_timeout_add_seconds(remaining_time, 1.45 periodic_check, self); 1.46 + 1.47 + g_debug("perioidic checks no longer inhibited, time since " 1.48 + "last check: %ds, next check in: %ds", elapsed_time, 1.49 + remaining_time); 1.50 } 1.51 } 1.52