dia r4230 - in trunk: . lib



Author: hans
Date: Sun Jan 25 20:59:20 2009
New Revision: 4230
URL: http://svn.gnome.org/viewvc/dia?rev=4230&view=rev

Log:
2009-01-24  Hans Breuer  <hans breuer org>

	* lib/message.[ch] lib/libdia.def : new function dia_log_message() 
	which prints the given string together with a time-stamp, but only 
	if logging is enabled
	* app/app_procs.c lib/dialib.[ch] : when given --verbose enable logging
	* lib/plug-ins.c lib/sheet.c : sprinkled some dia_log_message() to get
	a grip on Dia's start-up performance (4 secs for python plug-in, 5 secs
	for custom plug-in - when started from cold caches)
	


Modified:
   trunk/ChangeLog
   trunk/lib/dialib.c
   trunk/lib/dialib.h
   trunk/lib/libdia.def
   trunk/lib/message.c
   trunk/lib/message.h
   trunk/lib/plug-ins.c
   trunk/lib/sheet.c

Modified: trunk/lib/dialib.c
==============================================================================
--- trunk/lib/dialib.c	(original)
+++ trunk/lib/dialib.c	Sun Jan 25 20:59:20 2009
@@ -97,6 +97,10 @@
   xmlSetGenericErrorFunc(NULL, myXmlErrorReporting);
 #endif
 
+  if (flags & DIA_VERBOSE) {
+    dia_log_message_enable (TRUE);
+    dia_log_message ("initializing libdia");
+  }
   stdprops_init();
 
   if (flags & DIA_INTERACTIVE) {

Modified: trunk/lib/dialib.h
==============================================================================
--- trunk/lib/dialib.h	(original)
+++ trunk/lib/dialib.h	Sun Jan 25 20:59:20 2009
@@ -8,7 +8,8 @@
 enum DiaInitFlags
 {
   DIA_INTERACTIVE = (1<<0),
-  DIA_MESSAGE_STDERR = (1<<1)
+  DIA_MESSAGE_STDERR = (1<<1),
+  DIA_VERBOSE = (1<<2)
 };
 
 void libdia_init (guint flags);

Modified: trunk/lib/libdia.def
==============================================================================
--- trunk/lib/libdia.def	(original)
+++ trunk/lib/libdia.def	Sun Jan 25 20:59:20 2009
@@ -704,3 +704,4 @@
  text_line_adjust_layout_line
  
  libdia_init
+ dia_log_message

Modified: trunk/lib/message.c
==============================================================================
--- trunk/lib/message.c	(original)
+++ trunk/lib/message.c	Sun Jan 25 20:59:20 2009
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+#define G_LOG_DOMAIN "Dia"
 #include <gtk/gtk.h>
 #include <glib.h>
 
@@ -292,3 +293,31 @@
   va_end (args);
   va_end (args2);
 }
+
+static gboolean log_enabled = FALSE;
+void 
+dia_log_message_enable (gboolean yes)
+{
+  log_enabled = yes;
+}
+
+void
+dia_log_message (const char *format, ...)
+{
+  static GTimer *timer = NULL;
+  char *log;
+  va_list args;
+
+  if (!log_enabled)
+     return;
+
+  if (!timer)
+    timer = g_timer_new ();
+
+  va_start (args, format);
+  log  = g_strdup_vprintf (format, args);
+  va_end (args);
+
+  g_message ("t=%.03f - %s", g_timer_elapsed (timer, NULL), log);
+  g_free (log);
+}

Modified: trunk/lib/message.h
==============================================================================
--- trunk/lib/message.h	(original)
+++ trunk/lib/message.h	Sun Jan 25 20:59:20 2009
@@ -38,6 +38,8 @@
 void message_warning(const char *format, ...);
 void message_error(const char *format, ...);
 
+void dia_log_message(const char *format, ...);
+void dia_log_message_enable (gboolean yes);
 /* also declared in dia_dirs.h, where I think it does not belong! --hb */
 const gchar *dia_message_filename (const gchar *filename);
 

Modified: trunk/lib/plug-ins.c
==============================================================================
--- trunk/lib/plug-ins.c	(original)
+++ trunk/lib/plug-ins.c	Sun Jan 25 20:59:20 2009
@@ -172,6 +172,7 @@
   error_mode = SetErrorMode (SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
 #endif
 
+  dia_log_message ("plug-in '%s'", info->filename);
   info->module = g_module_open(info->filename, G_MODULE_BIND_LAZY);
 #ifdef G_OS_WIN32
     SetErrorMode (error_mode);

Modified: trunk/lib/sheet.c
==============================================================================
--- trunk/lib/sheet.c	(original)
+++ trunk/lib/sheet.c	Sun Jan 25 20:59:20 2009
@@ -122,12 +122,15 @@
   sheets = g_slist_sort(sheets, dia_sheet_sort_callback);
 }
 
-void load_all_sheets(void) {
+void 
+load_all_sheets(void) 
+{
   char *sheet_path;
   char *home_dir;
 
   home_dir = dia_config_filename("sheets");
   if (home_dir) {
+    dia_log_message (_("sheets from '%s'"), home_dir);
     load_sheets_from_dir(home_dir, SHEET_SCOPE_USER);
     g_free(home_dir);
   }
@@ -137,11 +140,14 @@
     char **dirs = g_strsplit(sheet_path,G_SEARCHPATH_SEPARATOR_S,0);
     int i;
 
-    for (i=0; dirs[i] != NULL; i++) 
+    for (i=0; dirs[i] != NULL; i++) {
+      dia_log_message (_("sheets from '%s'"), dirs[i]);
       load_sheets_from_dir(dirs[i], SHEET_SCOPE_SYSTEM);
+    }
     g_strfreev(dirs);
   } else {
     char *thedir = dia_get_data_directory("sheets");
+    dia_log_message (_("sheets from '%s'"), thedir);
     load_sheets_from_dir(thedir, SHEET_SCOPE_SYSTEM);
     g_free(thedir);
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]