f-spot r4700 - in trunk: . src src/Utils



Author: rubenv
Date: Mon Jan 19 15:33:25 2009
New Revision: 4700
URL: http://svn.gnome.org/viewvc/f-spot?rev=4700&view=rev

Log:
2009-01-19  Ruben Vermeersch  <ruben savanne be>

	* src/Utils/Log.cs: Add Trace log level and Trace + TraceFormat messages,
	which generate the needed syscalls for trace timelines.

	* src/main.cs: Parse the --strace to enable tracing.

	* src/f-spot.in: Add a --strace parameter to run f-spot under strace,
	which allows for the creation of trace timelines. More info:
	http://weblog.savanne.be/156-using-federicos-timeline-tool-with-mono

Modified:
   trunk/ChangeLog
   trunk/src/Utils/Log.cs
   trunk/src/f-spot.in
   trunk/src/main.cs

Modified: trunk/src/Utils/Log.cs
==============================================================================
--- trunk/src/Utils/Log.cs	(original)
+++ trunk/src/Utils/Log.cs	Mon Jan 19 15:33:25 2009
@@ -48,6 +48,7 @@
         
     public enum LogEntryType
     {
+        Trace,
         Debug,
         Warning,
         Error,
@@ -98,12 +99,22 @@
             get { return debugging; }
             set { debugging = value; }
         }
+
+        private static bool tracing = false;
+        public static bool Tracing {
+            get { return tracing; }
+            set { tracing = value; }
+        }
         
         public static void Commit (LogEntryType type, string message, string details, bool showUser)
         {
             if (type == LogEntryType.Debug && !Debugging) {
                 return;
             }
+
+            if (type == LogEntryType.Trace && !Tracing) {
+                return;
+            }
         
             if (type != LogEntryType.Information || (type == LogEntryType.Information && !showUser)) {
                 switch (type) {
@@ -111,6 +122,7 @@
                     case LogEntryType.Warning: ConsoleCrayon.ForegroundColor = ConsoleColor.Yellow; break;
                     case LogEntryType.Information: ConsoleCrayon.ForegroundColor = ConsoleColor.Green; break;
                     case LogEntryType.Debug: ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; break;
+                    case LogEntryType.Trace: ConsoleCrayon.ForegroundColor = ConsoleColor.Magenta; break;
                 }
                 
                 Console.Write ("[{0} {1:00}:{2:00}:{3:00}.{4:000}]", TypeString (type), DateTime.Now.Hour,
@@ -128,6 +140,11 @@
             if (showUser) {
                 OnNotify (new LogEntry (type, message, details));
             }
+
+            if (type == LogEntryType.Trace) {
+                string str = String.Format ("MARK: {0}: {1}", message, details);
+                Mono.Unix.Native.Syscall.access(str, Mono.Unix.Native.AccessModes.F_OK);
+            }
         }
 
         private static string TypeString (LogEntryType type)
@@ -137,6 +154,7 @@
                 case LogEntryType.Warning:       return "Warn ";
                 case LogEntryType.Error:         return "Error";
                 case LogEntryType.Information:   return "Info ";
+                case LogEntryType.Trace:         return "Trace";
             }
             return null;
         }
@@ -253,6 +271,24 @@
         }
         
         #endregion
+
+        #region Public Trace Methods
+
+        public static void Trace (string group, string details)
+        {
+            if (Tracing) {
+                Commit (LogEntryType.Trace, group, details, false);
+            }
+        }
+
+        public static void TraceFormat (string group, string format, params object [] args)
+        {
+            if (Tracing) {
+                Trace (group, String.Format (format, args));
+            }
+        }
+
+        #endregion
         
         #region Public Debug Methods
                                     

Modified: trunk/src/f-spot.in
==============================================================================
--- trunk/src/f-spot.in	(original)
+++ trunk/src/f-spot.in	Mon Jan 19 15:33:25 2009
@@ -29,6 +29,7 @@
 run_mdb=false
 run_gdb=false
 run_valgrind=false
+run_strace=false
 basedir_set=false
 for arg in "$@"; do
     case "x$arg" in
@@ -47,9 +48,12 @@
 	x--valgrind)
 	    run_valgrind=true
 	    ;;
-    	x--trace=*)
+	x--trace=*)
 	    FSPOT_TRACE="$arg"
 	    ;;
+	x--strace)
+	    run_strace=true
+	    ;;
 	x--profile=*)
 	    FSPOT_PROFILE="$arg"
 	    ;;
@@ -92,6 +96,8 @@
 	gdb --eval-command=run --args mono $MONO_OPTIONS $EXE_TO_RUN "$@"
 elif $run_valgrind; then
 	valgrind --tool=memcheck --leak-check=full --show-reachable=yes --log-file=valgrind --smc-check=all --suppressions=/home/sde/Mono/mono/data/mono.supp mono $MONO_OPTIONS $EXE_TO_RUN "$@"
+elif $run_strace; then
+	strace -ttt -f -o /tmp/f-spot.strace mono $MONO_OPTIONS $EXE_TO_RUN "$@"
 else
 	exec -a @PACKAGE@ $DBUSLAUNCH mono $MONO_OPTIONS $EXE_TO_RUN "$@"
 fi

Modified: trunk/src/main.cs
==============================================================================
--- trunk/src/main.cs	(original)
+++ trunk/src/main.cs	Mon Jan 19 15:33:25 2009
@@ -133,6 +133,10 @@
 					Version ();
 					return 0;
 
+				case "--strace":
+					Log.Tracing = true;
+					break;
+
 				case "--debug":
 					Log.Debugging = true;
 					// Debug GdkPixbuf critical warnings



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