banshee r3032 - in trunk/banshee: . src/Core src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.Services/Banshee.ServiceStack



Author: abock
Date: Sat Jan 26 23:25:31 2008
New Revision: 3032
URL: http://svn.gnome.org/viewvc/banshee?rev=3032&view=rev

Log:
2008-01-26  Aaron Bockover  <abockover novell com>

    * src/Core/Banshee.Core/Banshee.Base/Log.cs: Only show debug message if
    we are running in --debug mode

    * src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs: Spew
    some awesome timing/debug messages

    * src/Core/Makefile.am: Fix a boo-boo



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
   trunk/banshee/src/Core/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Log.cs	Sat Jan 26 23:25:31 2008
@@ -96,6 +96,10 @@
         
         private static void Commit (LogEntryType type, string message, string details, bool showUser)
         {
+            if (type == LogEntryType.Debug && !ApplicationContext.Debugging) {
+                return;
+            }
+        
             if (type != LogEntryType.Information || (type == LogEntryType.Information && !showUser)) {
                 switch (type) {
                     case LogEntryType.Error: Console.ForegroundColor = ConsoleColor.Red; break;
@@ -133,27 +137,41 @@
                                     
         public static void Debug (string message, string details)
         {
-            Commit (LogEntryType.Debug, message, details, false);
+            if (ApplicationContext.Debugging) {
+                Commit (LogEntryType.Debug, message, details, false);
+            }
         }
         
         public static void Debug (string message)
         {
-            Debug (message, null);
+            if (ApplicationContext.Debugging) {
+                Debug (message, null);
+            }
         }
         
         public static void DebugFormat (string format, params object [] args)
         {
-            Debug (String.Format (format, args));
+            if (ApplicationContext.Debugging) {
+                Debug (String.Format (format, args));
+            }
         }
         
         public static uint DebugTimerStart (string message)
         {
+            if (!ApplicationContext.Debugging) {
+                return 0;
+            }
+            
             Debug (message);
             return DebugTimerStart ();
         }
         
         public static uint DebugTimerStart ()
         {
+            if (!ApplicationContext.Debugging) {
+                return 0;
+            }
+            
             uint timer_id = next_timer_id++;
             timers.Add (timer_id, DateTime.Now);
             return timer_id;
@@ -161,11 +179,19 @@
         
         public static void DebugTimerPrint (uint id)
         {
+            if (!ApplicationContext.Debugging) {
+                return;
+            }
+            
             DebugTimerPrint (id, "Operation duration: {0}");
         }
         
         public static void DebugTimerPrint (uint id, string message)
         {
+            if (!ApplicationContext.Debugging) {
+                return;
+            }
+            
             DateTime finish = DateTime.Now;
             
             if (!timers.ContainsKey (id)) {
@@ -173,7 +199,14 @@
             }
             
             TimeSpan duration = finish - timers[id];
-            DebugFormat (message, duration);
+            string d_message;
+            if (duration.TotalSeconds < 60) {
+                d_message = String.Format ("{0}s", duration.TotalSeconds);
+            } else {
+                d_message = duration.ToString ();
+            }
+            
+            DebugFormat (message, d_message);
         }
         
         #endregion
@@ -187,7 +220,7 @@
         
         public static void Information (string message, string details)
         {
-            Information (message, details, true);
+            Information (message, details, false);
         }
         
         public static void Information (string message, string details, bool showUser)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs	Sat Jan 26 23:25:31 2008
@@ -83,20 +83,30 @@
             lock (self_mutex) {          
                 OnStartupBegin ();
                 
+                uint cumulative_timer_id = Log.DebugTimerStart ();
+                
                 foreach (Type type in service_types) {
+                    uint timer_id = Log.DebugTimerStart (); 
                     IService service = (IService)Activator.CreateInstance (type);
                     RegisterServiceNoLock (service);
+                    Log.DebugTimerPrint (timer_id, String.Format (
+                        "Core service started ({0}, {{0}})", service.ServiceName));
                     OnServiceStarted (service);
                 }
                 
                 foreach (TypeExtensionNode node in extension_nodes) {
+                    uint timer_id = Log.DebugTimerStart ();
                     IService service = (IService)node.CreateInstance (typeof (IService));
                     RegisterServiceNoLock (service);
+                    Log.DebugTimerPrint (timer_id, String.Format (
+                        "Extension service started ({0}, {{0}})", service.ServiceName));
                     OnServiceStarted (service);
                 }
                 
                 is_initialized = true;
                 
+                Log.DebugTimerPrint (cumulative_timer_id, "All services are started {0}");
+                
                 OnStartupFinished ();
             }
         }
@@ -180,7 +190,6 @@
         
         private static void OnServiceStarted (IService service)
         {
-            Log.Debug ("Started service", service.ServiceName);
             ServiceStartedHandler handler = ServiceStarted;
             if (handler != null) {
                 handler (new ServiceStartedArgs (service));

Modified: trunk/banshee/src/Core/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Makefile.am	(original)
+++ trunk/banshee/src/Core/Makefile.am	Sat Jan 26 23:25:31 2008
@@ -18,7 +18,7 @@
 	for dir in $(MONO_ADDINS_PATH); do \
 		cp $$dir/*.{dll,mdb,config} .run.tmp/Addins 2>/dev/null; \
 	done; \
-	cp $(top_builddir)/libbanshee/.libs/libbanshee.so .run.tmp || $(top_builddir)/libbanshee/libbanshee.so; \
+	cp $(top_builddir)/libbanshee/.libs/libbanshee.so .run.tmp || cp $(top_builddir)/libbanshee/libbanshee.so; .run.tmp; \
 	pushd .run.tmp; \
 	echo "<Addins><Directory>./Addins</Directory></Addins>" > Nereid.addins; \
 	$(MONO) --debug Nereid.exe --debug --uninstalled $(BANSHEE_DEV_OPTIONS); \



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