diff options
author | Thomas Haller <thaller@redhat.com> | 2017-04-22 21:06:12 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-12 17:29:33 +0200 |
commit | 615aa3f0777e9421ccaf888a44d98d968737bba8 (patch) | |
tree | e9d7fdfefefe8aa3cada1df91ea70dbd879e0406 | |
parent | f61b1dadaee208967c765a2ca235a4b8dbd9f291 (diff) | |
download | NetworkManager-615aa3f0777e9421ccaf888a44d98d968737bba8.tar.gz |
modem: prettify logging output about available ModemManager/oFono
These lines are logged with <info> level. They should look pleasant.
-rw-r--r-- | src/devices/wwan/nm-modem-manager.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c index b5aa60c87a..3dd9377699 100644 --- a/src/devices/wwan/nm-modem-manager.c +++ b/src/devices/wwan/nm-modem-manager.c @@ -70,6 +70,15 @@ typedef struct { gulong handle_object_removed_id; guint relaunch_id; + /* this only has one use: that the <info> logging line about + * ModemManager available distinguishes between first-time + * and later name-owner-changed. */ + enum { + LOG_AVAILABLE_NOT_INITIALIZED = 0, + LOG_AVAILABLE_YES, + LOG_AVAILABLE_NO, + } log_available:3; + GDBusProxy *proxy; GCancellable *proxy_cancellable; guint proxy_ref_count; @@ -219,7 +228,10 @@ modm_manager_available (NMModemManager *self) NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self); GList *modems, *l; - _LOGI ("ModemManager available in the bus"); + if (priv->modm.log_available != LOG_AVAILABLE_YES) { + _LOGI ("ModemManager %savailable", priv->modm.log_available ? "now " : ""); + priv->modm.log_available = LOG_AVAILABLE_YES; + } /* Update initial modems list */ modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (priv->modm.manager)); @@ -241,7 +253,10 @@ modm_handle_name_owner_changed (MMManager *modem_manager, name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (modem_manager)); if (!name_owner) { - _LOGI ("ModemManager disappeared from bus"); + if (priv->modm.log_available != LOG_AVAILABLE_NO) { + _LOGI ("ModemManager %savailable", priv->modm.log_available ? "no longer " : "not "); + priv->modm.log_available = LOG_AVAILABLE_NO; + } /* If not managed by systemd, schedule relaunch */ if (!sd_booted ()) @@ -659,14 +674,14 @@ ofono_enumerate_devices_done (GObject *proxy, } static void -ofono_check_name_owner (NMModemManager *self) +ofono_check_name_owner (NMModemManager *self, gboolean first_invocation) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self); gs_free char *name_owner = NULL; name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (priv->ofono.proxy)); if (name_owner) { - _LOGI ("oFono is now available"); + _LOGI ("oFono is %savailable", first_invocation ? "" : "now "); nm_clear_g_cancellable (&priv->ofono.cancellable); priv->ofono.cancellable = g_cancellable_new (); @@ -683,7 +698,7 @@ ofono_check_name_owner (NMModemManager *self) GHashTableIter iter; NMModem *modem; - _LOGI ("oFono disappeared from bus"); + _LOGI ("oFono is %savailable", first_invocation ? "not " : "no longer "); /* Remove any oFono modems that might be left around */ g_hash_table_iter_init (&iter, priv->modems); @@ -701,7 +716,7 @@ ofono_name_owner_changed (GDBusProxy *ofono_proxy, GParamSpec *pspec, NMModemManager *self) { - ofono_check_name_owner (self); + ofono_check_name_owner (self, FALSE); } static void @@ -741,7 +756,7 @@ ofono_proxy_new_cb (GObject *source_object, G_CALLBACK (ofono_signal_cb), self); - ofono_check_name_owner (self); + ofono_check_name_owner (self, TRUE); } static void |