Author: mhabersack
Date: 2007-03-30 05:34:40 -0500 (Fri, 30 Mar 2007)
New Revision: 75182
Added:
trunk/xsp/src/Mono.WebServer/Tracing.cs
Modified:
trunk/xsp/ChangeLog
trunk/xsp/configure.in
trunk/xsp/src/Mono.WebServer/Makefile.am
Log:
2007-03-30 Marek Habersack <[EMAIL PROTECTED]>
* src/Mono.WebServer/Tracing.cs: added a utility class to help in
tracing.
* src/Mono.WebServer/Makefile.am (monowebserver_sources): added
Tracing.cs
* configure.in: Define TRACE together with WEBTRACE.
Modified: trunk/xsp/ChangeLog
===================================================================
--- trunk/xsp/ChangeLog 2007-03-30 09:40:42 UTC (rev 75181)
+++ trunk/xsp/ChangeLog 2007-03-30 10:34:40 UTC (rev 75182)
@@ -1,13 +1,18 @@
2007-03-30 Marek Habersack <[EMAIL PROTECTED]>
+ * src/Mono.WebServer/Tracing.cs: added a utility class to help in
+ tracing.
+
* src/server.cs: move a line of common code out of ifdefs
* src/Mono.WebServer/Makefile.am (MCSFLAGS): support tracing if
enabled.
+ (monowebserver_sources): added Tracing.cs
* src/Makefile.am (MCSFLAGS): support tracing if enabled
* configure.in: add a parameter to enable conditional tracing.
+ Define TRACE together with WEBTRACE.
2007-03-29 Miguel de Icaza <[EMAIL PROTECTED]>
Modified: trunk/xsp/configure.in
===================================================================
--- trunk/xsp/configure.in 2007-03-30 09:40:42 UTC (rev 75181)
+++ trunk/xsp/configure.in 2007-03-30 10:34:40 UTC (rev 75182)
@@ -22,7 +22,7 @@
if test "x$enable_tracing" != "xno" ; then
AC_MSG_RESULT([yes])
- WEBTRACING="-define:WEBTRACE"
+ WEBTRACING="-define:WEBTRACE -define:TRACE"
else
AC_MSG_RESULT([no])
WEBTRACING=""
Modified: trunk/xsp/src/Mono.WebServer/Makefile.am
===================================================================
--- trunk/xsp/src/Mono.WebServer/Makefile.am 2007-03-30 09:40:42 UTC (rev
75181)
+++ trunk/xsp/src/Mono.WebServer/Makefile.am 2007-03-30 10:34:40 UTC (rev
75182)
@@ -31,7 +31,9 @@
LingeringNetworkStream.cs \
MonoWorkerRequest.cs \
XSPApplicationHost.cs \
- XSPWorkerRequest.cs
+ XSPWorkerRequest.cs \
+ Tracing.cs
+
monowebserver_build_sources = $(addprefix $(srcdir)/,
$(monowebserver_sources)) $(addprefix $(top_builddir)/src/Mono.WebServer/,
AssemblyInfo.cs)
monowebserver2_build_sources = $(addprefix $(srcdir)/,
$(monowebserver_sources)) $(addprefix $(top_builddir)/src/Mono.WebServer/,
AssemblyInfo2.cs)
Added: trunk/xsp/src/Mono.WebServer/Tracing.cs
===================================================================
--- trunk/xsp/src/Mono.WebServer/Tracing.cs 2007-03-30 09:40:42 UTC (rev
75181)
+++ trunk/xsp/src/Mono.WebServer/Tracing.cs 2007-03-30 10:34:40 UTC (rev
75182)
@@ -0,0 +1,126 @@
+//
+// ApplicationServer.cs
+//
+// Authors:
+// Marek Habersack ([EMAIL PROTECTED])
+//
+// Copyright (c) Copyright 2007 Novell, Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Threading;
+using System.Diagnostics;
+using System.Reflection;
+
+namespace Mono.WebServer
+{
+ public sealed class WebTrace
+ {
+ static string GetMethodName (StackFrame sf)
+ {
+ MethodBase mi = sf.GetMethod ();
+
+ if (mi != null)
+ return String.Format ("{0}.{1} ",
mi.ReflectedType, mi.Name);
+ return null;
+ }
+
+ static string GetExtraInfo (StackFrame sf)
+ {
+#if NET_2_0
+ string threadid = String.Format (" [thread_id: {0}",
Thread.CurrentThread.ManagedThreadId.ToString ("x"));
+#else
+ string threadid = String.Format (" [thread_hash: {0}",
Thread.CurrentThread.GetHashCode ().ToString ("x"));
+#endif
+
+ string filepath = sf != null ? sf.GetFileName () : null;
+ if (filepath != null && filepath.Length > 0)
+ return String.Format ("{0}, in {1}:{2}]",
threadid, filepath, sf.GetFileLineNumber ());
+ else
+ return String.Format ("{0}]", threadid);
+ }
+
+ static string GetExtraInfo ()
+ {
+ return GetExtraInfo (null);
+ }
+
+ [Conditional ("WEBTRACE")]
+ public static void Enter (string format, params object[] parms)
+ {
+ StringBuilder sb = new StringBuilder ("Enter: ");
+ StackFrame sf = new StackFrame (1);
+
+ string methodName = GetMethodName (sf);
+ if (methodName != null)
+ sb.Append (methodName);
+ if (format != null)
+ sb.AppendFormat (format, parms);
+ sb.Append (GetExtraInfo (sf));
+
+ Trace.WriteLine (sb.ToString ());
+ Trace.Indent ();
+ }
+
+ [Conditional ("WEBTRACE")]
+ public static void Enter ()
+ {
+ Enter (null, null);
+ }
+
+ [Conditional ("WEBTRACE")]
+ public static void Leave (string format, params object[] parms)
+ {
+ StringBuilder sb = new StringBuilder ("Leave: ");
+ StackFrame sf = new StackFrame (1);
+
+ string methodName = GetMethodName (sf);
+ if (methodName != null)
+ sb.Append (methodName);
+ if (format != null)
+ sb.AppendFormat (format, parms);
+ sb.Append (GetExtraInfo (sf));
+
+ Trace.Unindent ();
+ Trace.WriteLine (sb.ToString ());
+ }
+
+ [Conditional ("WEBTRACE")]
+ public static void Leave ()
+ {
+ Leave (null, null);
+ }
+
+ [Conditional ("WEBTRACE")]
+ public static void WriteLine (string format, params object[]
parms)
+ {
+ if (format == null)
+ return;
+
+ StringBuilder sb = new StringBuilder ();
+ sb.AppendFormat (format, parms);
+ sb.Append (GetExtraInfo ());
+ Trace.WriteLine (sb.ToString ());
+ }
+ }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches