[Galago-commits] r2347 - in trunk/galago-daemon: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Nov 27 21:04:52 PST 2005
Author: chipx86
Date: 2005-11-27 21:04:44 -0800 (Sun, 27 Nov 2005)
New Revision: 2347
Modified:
trunk/galago-daemon/ChangeLog
trunk/galago-daemon/src/core.c
trunk/galago-daemon/src/filter.c
trunk/galago-daemon/src/galagod.c
trunk/galago-daemon/src/logging.c
trunk/galago-daemon/src/person-list.c
trunk/galago-daemon/src/person.c
trunk/galago-daemon/src/service.c
trunk/galago-daemon/src/utils.c
trunk/galago-daemon/src/utils.h
Log:
Moved to using the glib logging functions instead of the old galago_log_* functions.
Modified: trunk/galago-daemon/ChangeLog
===================================================================
--- trunk/galago-daemon/ChangeLog 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/ChangeLog 2005-11-28 05:04:44 UTC (rev 2347)
@@ -1,3 +1,17 @@
+Sun Nov 27 15:43:25 PST 2005 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/core.c:
+ * src/filter.c:
+ * src/galagod.c:
+ * src/logging.c:
+ * src/person.c:
+ * src/person-list.c:
+ * src/service.c:
+ * src/utils.c:
+ * src/utils.h:
+ - Moved to using the glib logging functions instead of the old
+ galago_log_* functions.
+
Thu Nov 24 17:24:37 PST 2005 Christian Hammond <chipx86 at chipx86.com>
* src/meta-presence.c:
Modified: trunk/galago-daemon/src/core.c
===================================================================
--- trunk/galago-daemon/src/core.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/core.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -77,8 +77,8 @@
g_object_set_data(G_OBJECT(person), "coco", coco);
- galago_log_misc("Adding person with ID %s (%p)\n",
- galago_person_get_id(person), person);
+ g_message("Adding person with ID %s (%p)",
+ galago_person_get_id(person), person);
galagod_people_add(person);
galagod_dbus_send_empty_reply(conn, message);
@@ -168,13 +168,9 @@
dbus_message_iter_get_basic(&iter, &name);
dbus_message_iter_next(&iter);
- galago_log_misc("name = %s\n", name);
-
dbus_message_iter_get_basic(&iter, &feed);
dbus_message_iter_next(&iter);
- galago_log_misc("feed = %d\n", feed);
-
coco = galagod_coco_new(name, feed, dbus_message_get_sender(message));
if (coco == NULL)
@@ -204,6 +200,11 @@
dbus_connection_send(dbus_conn, reply, NULL);
dbus_message_unref(reply);
+ if (feed)
+ g_message("Feed '%s' registered.", name);
+ else
+ g_message("Client '%s' registered.", name);
+
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -221,9 +222,8 @@
if (coco == NULL)
{
- galago_log_error("Attempted to unregister a non-existant CoCo "
- "with path %s\n",
- obj_path);
+ g_warning("Attempted to unregister a non-existant CoCo with path %s",
+ obj_path);
return DBUS_HANDLER_RESULT_HANDLED;
}
Modified: trunk/galago-daemon/src/filter.c
===================================================================
--- trunk/galago-daemon/src/filter.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/filter.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -114,9 +114,9 @@
if (dbus_message_get_path(message) == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- galago_log_misc("%s: %s\n",
- dbus_message_get_interface(message),
- dbus_message_get_member(message));
+ g_message("%s: %s",
+ dbus_message_get_interface(message),
+ dbus_message_get_member(message));
for (cmd = cmd_table; cmd->name != NULL; cmd++)
{
@@ -124,13 +124,10 @@
return cmd->func(dbus_conn, message, coco, data);
}
- galago_log_warning("Unhandled message!\n");
- galago_log_misc("\tobj_path = '%s'\n",
- dbus_message_get_path(message));
- galago_log_misc("\tinterface = '%s'\n",
- dbus_message_get_interface(message));
- galago_log_misc("\tmethod = '%s'\n",
- dbus_message_get_member(message));
+ g_warning("Unhandled message!");
+ g_warning("\tobj_path = '%s'", dbus_message_get_path(message));
+ g_warning("\tinterface = '%s'", dbus_message_get_interface(message));
+ g_warning("\tmethod = '%s'", dbus_message_get_member(message));
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
Modified: trunk/galago-daemon/src/galagod.c
===================================================================
--- trunk/galago-daemon/src/galagod.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/galagod.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -60,7 +60,7 @@
if (!g_file_test(path, G_FILE_TEST_IS_DIR))
{
- galago_log_error("%s should be a directory. Please fix this.\n", path);
+ g_error("%s should be a directory. Please fix this.", path);
return;
}
@@ -77,17 +77,17 @@
if (g_file_test(path, G_FILE_TEST_IS_EXECUTABLE))
{
- galago_log_info("Launching feed %s\n", filename);
+ g_message("Launching feed %s", filename);
if (!g_spawn_command_line_async(filename, &error))
{
- galago_log_error("Unable to execute %s: %s\n",
- filename, error->message);
+ g_warning("Unable to execute %s: %s",
+ filename, error->message);
}
}
else
{
- galago_log_warning("%s is not an executable.\n", filename);
+ g_warning("%s is not an executable.", filename);
}
g_free(filename);
@@ -97,8 +97,7 @@
}
else
{
- galago_log_error("Unable to open directory %s: %s\n",
- path, error->message);
+ g_error("Unable to open directory %s: %s", path, error->message);
}
if (error != NULL)
@@ -136,7 +135,7 @@
if (!galago_init(GALAGO_DAEMON_ID, FALSE))
{
- galago_log_fatal("Unable to initialize Galago\n");
+ g_critical("Unable to initialize Galago");
exit(1);
}
@@ -150,8 +149,8 @@
if (dbus_error_is_set(&dbus_error))
{
- galago_log_fatal("Unable to acquire service %s: %s\n",
- GALAGO_DBUS_SERVICE, dbus_error.message);
+ g_critical("Unable to acquire service %s: %s",
+ GALAGO_DBUS_SERVICE, dbus_error.message);
dbus_error_free(&dbus_error);
galago_uninit();
Modified: trunk/galago-daemon/src/logging.c
===================================================================
--- trunk/galago-daemon/src/logging.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/logging.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -25,33 +25,52 @@
static char *_filename = NULL;
static gboolean _verbose = FALSE;
static FILE *_fp = NULL;
+static guint _domain_log_handler_id = 0;
+static guint _glib_log_handler_id = 0;
+static guint _galago_log_handler_id = 0;
-static const char *level_names[] =
+static const gchar *
+get_log_level_name(GLogLevelFlags log_level)
{
- NULL, "MISC", "INFO", "WARNING", "ERROR", "FATAL", "ASSERT"
-};
+ switch (log_level)
+ {
+ case G_LOG_LEVEL_ERROR: return "ERROR";
+ case G_LOG_LEVEL_CRITICAL: return "CRITICAL";
+ case G_LOG_LEVEL_WARNING: return "WARNING";
+ case G_LOG_LEVEL_MESSAGE: return "INFO";
+ case G_LOG_LEVEL_INFO: return "INFO";
+ case G_LOG_LEVEL_DEBUG: return "DEBUG";
+ default:
+ g_return_val_if_reached("UNKNOWN");
+ }
+}
static void
-log_handler(GalagoLogLevel level, const char *msg, va_list args,
- void *user_data)
+output_log_info(FILE *fp, const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message)
{
- if (_fp != NULL)
+ if (log_domain != NULL)
{
- va_list tmp;
+ fprintf(fp, "%s: %s: %s\n",
+ log_domain, get_log_level_name(log_level), message);
+ }
+ else
+ {
+ fprintf(fp, "%s: %s\n", get_log_level_name(log_level), message);
+ }
- fprintf(_fp, "%s: ", level_names[level]);
- G_VA_COPY(tmp, args);
- vfprintf(_fp, msg, tmp);
- va_end(tmp);
+ fflush(fp);
+}
- fflush(_fp);
- }
+static void
+log_handler(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer user_data)
+{
+ if (_fp != NULL)
+ output_log_info(_fp, log_domain, log_level, message);
if (_verbose)
- {
- printf("galagod:%s: ", level_names[level]);
- vprintf(msg, args);
- }
+ output_log_info(stderr, log_domain, log_level, message);
}
void
@@ -77,10 +96,23 @@
if (_filename != NULL)
{
if ((_fp = fopen(_filename, "w")) == NULL)
- galago_log_fatal("Can't open log file %s for writing\n", _filename);
+ g_error("Can't open log file %s for writing", _filename);
}
- galago_log_set_handler(GALAGO_LOG_ALL, log_handler, NULL);
+ _domain_log_handler_id =
+ g_log_set_handler(NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION,
+ log_handler, NULL);
+
+ _glib_log_handler_id =
+ g_log_set_handler("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION,
+ log_handler, NULL);
+
+ _galago_log_handler_id =
+ g_log_set_handler("Galago", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+ G_LOG_FLAG_RECURSION,
+ log_handler, NULL);
}
void
@@ -98,5 +130,7 @@
_filename = NULL;
}
- galago_log_unset_handler(GALAGO_LOG_ALL);
+ g_log_remove_handler(NULL, _domain_log_handler_id);
+ g_log_remove_handler(NULL, _glib_log_handler_id);
+ g_log_remove_handler(NULL, _galago_log_handler_id);
}
Modified: trunk/galago-daemon/src/person-list.c
===================================================================
--- trunk/galago-daemon/src/person-list.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/person-list.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -57,8 +57,7 @@
const GList *l;
GList *tmp_meta_people = NULL;
- galago_log_info("Merging person %p into meta-person %p\n",
- person, meta_person);
+ g_message("Merging person %p into meta-person %p", person, meta_person);
for (l = galago_person_get_accounts(person, FALSE);
l != NULL;
@@ -150,7 +149,7 @@
for (l = galago_context_get_people(GALAGO_REMOTE); l != NULL; l = l->next)
{
- galago_log_info("Removing person %p\n", l->data);
+ g_message("Removing person %p", l->data);
galagod_people_remove((GalagoPerson *)l->data);
}
Modified: trunk/galago-daemon/src/person.c
===================================================================
--- trunk/galago-daemon/src/person.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/person.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -139,8 +139,8 @@
}
default:
- galago_log_warning("Invalid property type %d passed to "
- "SetProperty\n", arg_type);
+ g_warning("Invalid property type %d passed to "
+ "SetProperty", arg_type);
success = FALSE;
break;
}
@@ -261,8 +261,8 @@
default:
/* This should never happen. */
- galago_log_fatal("Unknown property type %d for property %s\n",
- type, name);
+ g_warning("Unknown property type %d for property %s",
+ type, name);
break;
}
}
Modified: trunk/galago-daemon/src/service.c
===================================================================
--- trunk/galago-daemon/src/service.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/service.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -44,9 +44,9 @@
person = galago_account_get_person(account);
- galago_log_info("Added new account %s (%p) on service %s and person %p\n",
- galago_account_get_username(account), account,
- galago_service_get_id(service), person);
+ g_message("Added new account %s (%p) on service %s and person %p",
+ galago_account_get_username(account), account,
+ galago_service_get_id(service), person);
galagod_people_account_added(person);
@@ -94,8 +94,8 @@
dbus_message_iter_init(message, &iter);
dbus_message_iter_get_basic(&iter, &username);
- galago_log_info("Getting account for %s on %s\n", username,
- galago_service_get_id(service));
+ g_message("Getting account for %s on %s", username,
+ galago_service_get_id(service));
meta_service = GALAGOD_META_SERVICE(service);
account_list = galagod_meta_service_get_account_list(meta_service);
Modified: trunk/galago-daemon/src/utils.c
===================================================================
--- trunk/galago-daemon/src/utils.c 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/utils.c 2005-11-28 05:04:44 UTC (rev 2347)
@@ -43,112 +43,6 @@
dbus_message_unref(reply);
}
-static void
-dump_meta_account(GalagodMetaAccount *meta_account)
-{
- GList *accounts, *l;
-
- accounts = galagod_meta_account_get_accounts(meta_account);
-
- galago_log_misc(" meta_account %p \"%s\" (count %zu)\n",
- meta_account,
- galago_account_get_username(
- galagod_meta_account_get_account(meta_account)),
- g_list_length(accounts));
-
- for (l = accounts; l != NULL; l = l->next)
- {
- GalagoAccount *account = (GalagoAccount *)l->data;
- GalagodMetaPresence *meta_presence;
- GList *presences, *l2;
-
- meta_presence =
- GALAGOD_META_PRESENCE(galago_account_get_presence(account, FALSE));
-
- presences = galagod_meta_presence_get_presences(meta_presence);
-
- galago_log_misc(" %p (presence %p, count %zu)\n",
- account, meta_presence,
- g_list_length(presences));
-
- for (l2 = presences; l2 != NULL; l2 = l2->next)
- {
- GalagoPresence *presence = (GalagoPresence *)l2->data;
-
- galago_log_misc(" %p\n", presence);
- }
- }
-}
-
-void
-galagod_dump_data(void)
-{
- const GList *l, *l2;
-
- galago_log_misc("Services: (%zu)\n",
- galagod_services_get_meta_service_count());
-
- for (l = galagod_services_get_meta_services();
- l != NULL;
- l = l->next)
- {
- GList *services;
- GalagodMetaService *meta_service = (GalagodMetaService *)l->data;
- GalagodAccountList *account_list;
-
- services = galagod_meta_service_get_services(meta_service);
-
- galago_log_misc(" meta_service %p \"%s\" (count %zu)\n",
- meta_service,
- galago_service_get_name(
- galagod_meta_service_get_service(meta_service)),
- g_list_length(services));
-
- for (l2 = services; l2 != NULL; l2 = l2->next)
- {
- GalagoService *service = (GalagoService *)l2->data;
-
- galago_log_misc(" %p\n", service);
- }
-
- account_list = galagod_meta_service_get_account_list(meta_service);
-
- galago_log_misc(" Accounts: (%zu)\n",
- galagod_account_list_get_meta_account_count(account_list));
-
- for (l2 = galagod_account_list_get_meta_accounts(account_list);
- l2 != NULL;
- l2 = l2->next)
- {
- dump_meta_account((GalagodMetaAccount *)l2->data);
- }
- }
-
- galago_log_misc("People: (%zu)\n",
- galagod_people_get_meta_person_count());
-
- for (l = galagod_people_get_meta_people();
- l != NULL;
- l = l->next)
- {
- GList *people;
- GalagodMetaPerson *meta_person = (GalagodMetaPerson *)l->data;
-
- people = galagod_meta_person_get_people(meta_person);
-
- galago_log_misc(" meta_person %p \"%s\" (count %zu)\n",
- meta_person,
- galago_person_get_id(
- galagod_meta_person_get_person(meta_person)),
- g_list_length(people));
-
- for (l2 = people; l2 != NULL; l2 = l2->next)
- {
- galago_log_misc(" %p\n", l2->data);
- }
- }
-}
-
DBusMessage *
galagod_object_not_found_error_new(DBusMessage *message,
const char *str, ...)
Modified: trunk/galago-daemon/src/utils.h
===================================================================
--- trunk/galago-daemon/src/utils.h 2005-11-28 05:00:32 UTC (rev 2346)
+++ trunk/galago-daemon/src/utils.h 2005-11-28 05:04:44 UTC (rev 2347)
@@ -28,8 +28,6 @@
void galagod_dbus_send_empty_reply(DBusConnection *dbus_conn,
DBusMessage *message);
-void galagod_dump_data(void);
-
DBusMessage *galagod_object_not_found_error_new(DBusMessage *message,
const char *str, ...);
More information about the galago-commits
mailing list