From: Gregor Riepl Date: Thu, 5 Aug 2010 20:47:04 +0000 (+0200) Subject: Implemented logging into separate file for debugging X-Git-Url: https://vcs.maemo.org/git/?p=mtetherd;a=commitdiff_plain;h=dd7a19519034cfbc61171bd678dd23a39748b393 Implemented logging into separate file for debugging Modified changelog to use temporary version for test install Added dpkg build files to ignore list --- diff --git a/.gitignore b/.gitignore index 296a23d..44c3964 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ *.o *.so mtetherd +build-stamp +configure-stamp +debian/files +debian/mtetherd.substvars diff --git a/Makefile b/Makefile index 35a3d6d..b450922 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,9 @@ SBIN_DIR = $(PREFIX)/sbin DOC_DIR = $(PREFIX)/share/doc/mtetherd IMAGE_DIR = $(PREFIX)/share/pixmaps ETC_DIR = /etc +TMP_DIR = /tmp CC = gcc -CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -DIMAGE_DIR=\"$(IMAGE_DIR)\" -DSBIN_DIR=\"$(SBIN_DIR)\" +CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -DIMAGE_DIR=\"$(IMAGE_DIR)\" -DBIN_DIR=\"$(BIN_DIR)\" -DSBIN_DIR=\"$(SBIN_DIR)\" -DTMP_DIR=\"$(TMP_DIR)\" INCLUDES = $(shell pkg-config --cflags dbus-1 libhildondesktop-1 hal glib-2.0 gtk+-2.0) LDFLAGS = LIBS_DBUS = $(shell pkg-config --libs dbus-1) diff --git a/debian/changelog b/debian/changelog index 20d002c..0c2009b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mtetherd (0.2-1) unstable; urgency=low +mtetherd (0.1.99-1) unstable; urgency=low * Implemented mtetherd as status plugin * Enabling and disabling USB networking is now possible via the GUI diff --git a/hal.c b/hal.c index ff8eb57..de75d3a 100644 --- a/hal.c +++ b/hal.c @@ -29,7 +29,7 @@ static void mtetherd_hal_device_condition(LibHalContext *ctx, const char *udi, c MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(libhal_ctx_get_user_data(ctx)); if (plugin) { - g_message("Got HAL condition %s on %s: %s", condition, udi, detail); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got HAL condition %s on %s: %s", condition, udi, detail); //hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Got HAL condition %s on %s: %s", condition, udi, detail); if (strcmp("ButtonPressed", condition) == 0) { if (strcmp(USBDEV_PATH, udi) == 0) { @@ -44,12 +44,12 @@ static void mtetherd_hal_device_added(LibHalContext *ctx, const char *udi) { MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(libhal_ctx_get_user_data(ctx)); if (plugin) { - g_message("Got HAL device added on %s", udi); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got HAL device added on %s", udi); DBusError derr; dbus_error_init(&derr); char *interface = libhal_device_get_property_string(plugin->hal_context, udi, "net.interface", &derr); if (dbus_error_is_set(&derr)) { - g_warning("Error getting interface name of %s (%s): %s", udi, derr.name, derr.message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error getting interface name of %s (%s): %s", udi, derr.name, derr.message); dbus_error_free(&derr); } if (interface) { @@ -68,7 +68,7 @@ static void mtetherd_hal_device_removed(LibHalContext *ctx, const char *udi) { MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(libhal_ctx_get_user_data(ctx)); if (plugin) { - g_message("Got HAL device added on %s", udi); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got HAL device added on %s", udi); mtetherd_status_plugin_device_removed(plugin, udi); //plugin->priv->net_on = FALSE; //enable_button_set_text(plugin->priv->enable_button, plugin->priv->net_on); @@ -80,50 +80,50 @@ gboolean mtetherd_hal_init(MTetherDStatusPlugin *plugin) { GError *err = NULL; plugin->dbus_connection = hd_status_plugin_item_get_dbus_g_connection(HD_STATUS_PLUGIN_ITEM(plugin), DBUS_BUS_SYSTEM, &err); if (err) { - g_warning("Can't open DBUS connection: %s", err->message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't open DBUS connection: %s", err->message); g_error_free(err); err = NULL; return FALSE; } else { - g_message("Got DBUS Glib connection: %p", plugin->dbus_connection); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got DBUS Glib connection: %p", plugin->dbus_connection); } if (plugin->dbus_connection) { plugin->hal_context = libhal_ctx_new(); if (plugin->hal_context) { if (libhal_ctx_set_dbus_connection(plugin->hal_context, dbus_g_connection_get_connection(plugin->dbus_connection))) { if (!libhal_ctx_set_user_data(plugin->hal_context, plugin)) { - g_warning("Can't set user data of HAL context"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't set user data of HAL context"); } if (!libhal_ctx_set_device_condition(plugin->hal_context, mtetherd_hal_device_condition)) { - g_warning("Error assigning device condition callback"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error assigning device condition callback"); } if (!libhal_ctx_set_device_added(plugin->hal_context, mtetherd_hal_device_added)) { - g_warning("Error assigning device added callback"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error assigning device added callback"); } if (!libhal_ctx_set_device_removed(plugin->hal_context, mtetherd_hal_device_removed)) { - g_warning("Error assigning device removed callback"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error assigning device removed callback"); } DBusError derr; dbus_error_init(&derr); if (!libhal_ctx_init(plugin->hal_context, &derr)) { if (dbus_error_is_set(&derr)) { - g_warning("Error initializing HAL context (%s): %s", derr.name, derr.message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error initializing HAL context (%s): %s", derr.name, derr.message); dbus_error_free(&derr); } else { - g_warning("Error initializing HAL context: unknown error"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error initializing HAL context: unknown error"); } libhal_ctx_free(plugin->hal_context); plugin->hal_context = NULL; return FALSE; } } else { - g_warning("Can't set DBUS connection of HAL context"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't set DBUS connection of HAL context"); libhal_ctx_free(plugin->hal_context); plugin->hal_context = NULL; return FALSE; } } else { - g_warning("Can't allocate HAL context"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't allocate HAL context"); return FALSE; } } @@ -152,7 +152,7 @@ void mtetherd_hal_device_scan(MTetherDStatusPlugin *plugin) { int ndevices = 0; char **udis = libhal_find_device_by_capability(plugin->hal_context, "net", &ndevices, &derr); if (dbus_error_is_set(&derr)) { - g_warning("Error loading list of network devices (%s): %s", derr.name, derr.message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error loading list of network devices (%s): %s", derr.name, derr.message); dbus_error_free(&derr); } if (udis) { @@ -160,7 +160,7 @@ void mtetherd_hal_device_scan(MTetherDStatusPlugin *plugin) { for (i = 0; i < ndevices; i++) { char *interface = libhal_device_get_property_string(plugin->hal_context, udis[i], "net.interface", &derr); if (dbus_error_is_set(&derr)) { - g_warning("Error getting interface name of %s (%s): %s", udis[i], derr.name, derr.message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error getting interface name of %s (%s): %s", udis[i], derr.name, derr.message); dbus_error_free(&derr); } if (interface) { @@ -183,7 +183,7 @@ gboolean mtetherd_usb_state(MTetherDStatusPlugin *plugin) { dbus_error_init(&derr); dbus_bool_t plugged = libhal_device_get_property_bool(plugin->hal_context, USBDEV_PATH, "button.state.value", &derr); if (dbus_error_is_set(&derr)) { - g_warning("Error getting USB plugged status (%s): %s", derr.name, derr.message); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error getting USB plugged status (%s): %s", derr.name, derr.message); //hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Error getting USB plugged status (%s): %s", derr.name, derr.message); dbus_error_free(&derr); } else { diff --git a/mtetherd-net-setup.sh b/mtetherd-net-setup.sh index 1b93cbc..1de3181 100755 --- a/mtetherd-net-setup.sh +++ b/mtetherd-net-setup.sh @@ -21,5 +21,5 @@ ADDR=$2 DHCP_START=$3 DHCP_END=$4 -echo "$INTERFACE $ADDR $DHCP_START $DHCP_END" >> /tmp/mtetherd-net-setup.log +echo "Setting up routing for: $INTERFACE $ADDR $DHCP_START $DHCP_END" >> /tmp/mtetherd-net-setup.log diff --git a/mtetherd-net-shutdown.sh b/mtetherd-net-shutdown.sh index eb60d91..29018d4 100755 --- a/mtetherd-net-shutdown.sh +++ b/mtetherd-net-shutdown.sh @@ -18,5 +18,5 @@ INTERFACE=$1 -echo "$INTERFACE" >> /tmp/mtetherd-net-shutdown.log +echo "Shutting down routing for: $INTERFACE" >> /tmp/mtetherd-net-shutdown.log diff --git a/net.c b/net.c index 788aff6..43d49f9 100644 --- a/net.c +++ b/net.c @@ -21,6 +21,7 @@ #include #include #include "net.h" +#include "plugin.h" #define MTETHERD_DEVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_MTETHERD_DEVICE, MTetherDDevicePrivate)) @@ -127,7 +128,7 @@ void mtetherd_device_set_index(MTetherDDevice *self, guint index) { self->priv->dhcp_start = htonl(start); self->priv->dhcp_end = htonl(addr); } else { - g_warning("Invalid subnet index: %u (0..%u expected)", index, MAX_DEVICES - 1); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Invalid subnet index: %u (0..%u expected)", index, MAX_DEVICES - 1); } } } diff --git a/plugin.c b/plugin.c index a0b4d5f..61cc159 100644 --- a/plugin.c +++ b/plugin.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include "plugin.h" @@ -44,31 +45,44 @@ struct _MTetherDStatusPluginPrivate { gpointer devices; gboolean usb_plugged; MTetherDStatusPluginUsbNetState usbnet_state; + FILE *log_fp; + guint log_handler; }; #ifndef IMAGE_DIR #define IMAGE_DIR "/usr/share/pixmaps" #endif +#ifndef BIN_DIR +#define BIN_DIR "/usr/bin" +#endif #ifndef SBIN_DIR #define SBIN_DIR "/usr/sbin" #endif +#ifndef TMP_DIR +#define TMP_DIR "/tmp" +#endif // The UDI contains the MAC address and is thus unsuitable for // loaded status checking, so we just use the interface name static const char *USBNET_INTERFACE = "usb0"; +const char *MTETHERD_LOG_DOMAIN = "mtetherd"; HD_DEFINE_PLUGIN_MODULE(MTetherDStatusPlugin, mtetherd_status_plugin, HD_TYPE_STATUS_MENU_ITEM); static void mtetherd_status_plugin_class_finalize(MTetherDStatusPluginClass *klass) { } static void mtetherd_status_plugin_finalize(GObject *object) { - g_message("Destroying mtetherd status plugin"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Destroying mtetherd status plugin"); MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(object); if (plugin && plugin->priv) { mtetherd_hal_finalize(plugin); mtetherd_device_list_free(plugin->priv->devices); + if (plugin->priv->log_fp) { + g_log_remove_handler(MTETHERD_LOG_DOMAIN, plugin->priv->log_handler); + fclose(plugin->priv->log_fp); + } } } @@ -85,13 +99,13 @@ static void mtetherd_status_plugin_enable_button_set_text(MTetherDStatusPlugin * if (plugin && plugin->priv && plugin->priv->enable_button) { switch (plugin->priv->usbnet_state) { case MTETHERD_STATUS_PLUGIN_USB_NET_ENABLED: - hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "Toggle USB Networking", "Enabled"); + hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "USB networking", "Enabled"); break; case MTETHERD_STATUS_PLUGIN_USB_NET_DISABLED: - hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "Toggle USB Networking", "Disabled"); + hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "USB networking", "Disabled"); break; default: - hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "Toggle USB Networking", "Unknown"); + hildon_button_set_text(HILDON_BUTTON(plugin->priv->enable_button), "USB networking", "Unknown"); break; } } @@ -104,10 +118,10 @@ static void mtetherd_status_plugin_enable_button_clicked(GtkWidget *button, gpoi const char *arg; switch (plugin->priv->usbnet_state) { case MTETHERD_STATUS_PLUGIN_USB_NET_ENABLED: - arg = SBIN_DIR "mtetherd-usbnet-disable.sh"; + arg = SBIN_DIR "/mtetherd-usbnet-disable.sh"; break; case MTETHERD_STATUS_PLUGIN_USB_NET_DISABLED: - arg = SBIN_DIR "mtetherd-usbnet-enable.sh"; + arg = SBIN_DIR "/mtetherd-usbnet-enable.sh"; break; default: arg = NULL; @@ -115,9 +129,9 @@ static void mtetherd_status_plugin_enable_button_clicked(GtkWidget *button, gpoi } if (arg) { g_debug("Launching %s", arg); - const char *command[] = { "/usr/bin/sudo", arg, NULL }; + const char *command[] = { BIN_DIR "/sudo", arg, NULL }; if (!mtetherd_launch_script(command)) { - g_error("Error launching USB networking script"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking script"); } } } @@ -133,41 +147,87 @@ static void mtetherd_status_plugin_usb_plugged_show(MTetherDStatusPlugin *plugin } } +static void mtetherd_status_plugin_log(const gchar *domain, GLogLevelFlags level, const gchar *message, gpointer data) { + MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(data); + + if (plugin && plugin->priv && plugin->priv->log_fp) { + char *levelstr; + switch (level) { + case G_LOG_LEVEL_ERROR: + levelstr = "** Error **"; + break; + case G_LOG_LEVEL_CRITICAL: + levelstr = "** CRITICAL **"; + break; + case G_LOG_LEVEL_WARNING: + levelstr = "** Warning **"; + break; + case G_LOG_LEVEL_MESSAGE: + levelstr = "-- Notice --"; + break; + case G_LOG_LEVEL_INFO: + levelstr = "-- Info --"; + break; + case G_LOG_LEVEL_DEBUG: + levelstr = "(Debug)"; + break; + case G_LOG_FLAG_RECURSION: + levelstr = "** RECURSION **"; + break; + case G_LOG_FLAG_FATAL: + levelstr = "** FATAL **"; + break; + default: + levelstr = ""; + break; + } + g_fprintf(plugin->priv->log_fp, "mtetherd: %s %s\n", levelstr, message); + fflush(plugin->priv->log_fp); + } +} + static void mtetherd_status_plugin_init(MTetherDStatusPlugin *plugin) { plugin->priv = MTETHERD_STATUS_PLUGIN_GET_PRIVATE(plugin); - plugin->priv->enable_button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL); - if (plugin->priv->enable_button) { - GError *err = NULL; - GdkPixbuf *icon = gdk_pixbuf_new_from_file(IMAGE_DIR "/mtetherd-net-icon.png", &err); - if (err) { - g_warning("Can't load mtetherd icon: %s", err->message); - g_error_free(err); - err = NULL; + if (plugin->priv) { + plugin->priv->log_fp = fopen(TMP_DIR "/mtetherd-status.log", "a"); + if (plugin->priv->log_fp) { + plugin->priv->log_handler = g_log_set_handler(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MASK, mtetherd_status_plugin_log, plugin); + } + + plugin->priv->enable_button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL); + if (plugin->priv->enable_button) { + GError *err = NULL; + GdkPixbuf *icon = gdk_pixbuf_new_from_file(IMAGE_DIR "/mtetherd-net-icon.png", &err); + if (err) { + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Can't load mtetherd icon: %s", err->message); + g_error_free(err); + err = NULL; + } + if (icon) { + GtkWidget *image = gtk_image_new_from_pixbuf(icon); + hildon_button_set_image(HILDON_BUTTON(plugin->priv->enable_button), image); + hildon_button_set_image_position(HILDON_BUTTON(plugin->priv->enable_button), GTK_POS_LEFT); + g_object_unref(icon); + } + mtetherd_status_plugin_enable_button_set_text(plugin); + g_signal_connect(plugin->priv->enable_button, "clicked", G_CALLBACK(mtetherd_status_plugin_enable_button_clicked), plugin); + gtk_container_add(GTK_CONTAINER(plugin), plugin->priv->enable_button); + gtk_widget_show_all(plugin->priv->enable_button); } - if (icon) { - GtkWidget *image = gtk_image_new_from_pixbuf(icon); - hildon_button_set_image(HILDON_BUTTON(plugin->priv->enable_button), image); - hildon_button_set_image_position(HILDON_BUTTON(plugin->priv->enable_button), GTK_POS_LEFT); - g_object_unref(icon); + + if (mtetherd_hal_init(plugin)) { + plugin->priv->usb_plugged = mtetherd_usb_state(plugin); + plugin->priv->devices = mtetherd_device_list_new(); + mtetherd_hal_device_scan(plugin); + } else { + plugin->priv->usb_plugged = FALSE; } - mtetherd_status_plugin_enable_button_set_text(plugin); - g_signal_connect(plugin->priv->enable_button, "clicked", G_CALLBACK(mtetherd_status_plugin_enable_button_clicked), plugin); - gtk_container_add(GTK_CONTAINER(plugin), plugin->priv->enable_button); - gtk_widget_show_all(plugin->priv->enable_button); + + // Update the button status + mtetherd_status_plugin_usb_plugged_show(plugin); } - if (mtetherd_hal_init(plugin)) { - plugin->priv->usb_plugged = mtetherd_usb_state(plugin); - plugin->priv->devices = mtetherd_device_list_new(); - mtetherd_hal_device_scan(plugin); - } else { - plugin->priv->usb_plugged = FALSE; - } - - // Update the button status - mtetherd_status_plugin_usb_plugged_show(plugin); - hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Initialized mtetherd status plugin"); } @@ -181,21 +241,21 @@ void mtetherd_status_plugin_device_added(MTetherDStatusPlugin *plugin, MTetherDD mtetherd_status_plugin_enable_button_set_text(plugin); } hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Starting network on %s", interface); - g_debug("Launching " SBIN_DIR "/mtetherd-net-setup.sh"); + g_debug("Launching %s", SBIN_DIR "/mtetherd-net-setup.sh"); gchar *addr = mtetherd_device_get_addr(device); gchar *netmask = mtetherd_device_get_netmask(device); gchar *dhcp_start = mtetherd_device_get_dhcp_start(device); gchar *dhcp_end = mtetherd_device_get_dhcp_end(device); - const char *command[] = { "/usr/bin/sudo", SBIN_DIR "/mtetherd-net-setup.sh", interface, addr, netmask, dhcp_start, dhcp_end, NULL }; + const char *command[] = { BIN_DIR "/sudo", SBIN_DIR "/mtetherd-net-setup.sh", interface, addr, netmask, dhcp_start, dhcp_end, NULL }; if (!mtetherd_launch_script(command)) { - g_warning("Error launching USB networking setup script"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking setup script"); } g_free(addr); g_free(netmask); g_free(dhcp_start); g_free(dhcp_end); } else { - g_warning("Error adding network interface to list: Maximum number of devices exceeded"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error adding network interface to list: Maximum number of devices exceeded"); } } } @@ -211,14 +271,14 @@ void mtetherd_status_plugin_device_removed(MTetherDStatusPlugin *plugin, const g mtetherd_status_plugin_enable_button_set_text(plugin); } hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Shutting down network on %s", interface); - g_debug("Launching " SBIN_DIR "/mtetherd-net-shutdown.sh"); - const char *command[] = { "/usr/bin/sudo", SBIN_DIR "/mtetherd-net-shutdown.sh", interface, NULL }; + g_debug("Launching %s", SBIN_DIR "/mtetherd-net-shutdown.sh"); + const char *command[] = { BIN_DIR "/sudo", SBIN_DIR "/mtetherd-net-shutdown.sh", interface, NULL }; if (!mtetherd_launch_script(command)) { - g_warning("Error launching USB networking shutdown script"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking shutdown script"); } } if (!mtetherd_device_list_remove(plugin->priv->devices, udi)) { - g_warning("Error removing network interface from list: Not found"); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error removing network interface from list: Not found"); } } } diff --git a/plugin.h b/plugin.h index a7b8f40..a5a3a47 100644 --- a/plugin.h +++ b/plugin.h @@ -27,6 +27,9 @@ G_BEGIN_DECLS +// The logging domain for Glib log messages +const char *MTETHERD_LOG_DOMAIN; + #define TYPE_MTETHERD_STATUS_PLUGIN (mtetherd_status_plugin_get_type()) #define MTETHERD_STATUS_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_CAST((object), TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPlugin)) #define MTETHERD_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginClass)) diff --git a/util.c b/util.c index 4cb0928..c746bf9 100644 --- a/util.c +++ b/util.c @@ -22,11 +22,13 @@ #include #include #include +#include "util.h" +#include "plugin.h" static const char *MODULE_LIST = "/proc/modules"; gboolean mtetherd_scan_modules(const char *module) { - g_message("Scanning %s", MODULE_LIST); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Scanning %s", MODULE_LIST); FILE *fp = fopen(MODULE_LIST, "r"); if (!fp) { @@ -35,9 +37,9 @@ gboolean mtetherd_scan_modules(const char *module) { gboolean found = FALSE; char *line = NULL; while (!found && getline(&line, NULL, fp) != -1) { - g_debug("Checking if '%s' starts with %s...", line, module); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Checking if '%s' starts with %s...", line, module); if (g_str_has_prefix(line, module) == 0) { - g_message("Found %s", module); + g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Found %s", module); found = TRUE; } free(line);