Example #1
0
        private void Diagnostics_OutputDebugStackTrace(Diagnostics.LogMessage message)
        {
            StackFrame[] frames = message.StackTrace.GetFrames();
            int          i;

            for (i = 0; i < frames.Length; i++)
            {
                if (frames[i] == message.StackFrame)
                {
                    Diagnostics.LogFormat diagnosticsLogFormat = this.DiagnosticsLogFormat;
                    if (diagnosticsLogFormat == Diagnostics.LogFormat.Text)
                    {
                        this.outputDepugFileStreamWriter.WriteLine();
                    }
                    break;
                }
            }
            StringBuilder stringBuilder = new StringBuilder();

            while (i < frames.Length)
            {
                stringBuilder.Length = 0;
                StackFrame stackFrame = frames[i];
                stringBuilder.AppendFormat("{0}:{1}(", stackFrame.GetMethod().ReflectedType.ToString(), stackFrame.GetMethod().Name);
                ParameterInfo[] parameters = stackFrame.GetMethod().GetParameters();
                if (parameters.Length > 0)
                {
                    for (int j = 0; j < parameters.Length; j++)
                    {
                        if (j > 0)
                        {
                            stringBuilder.Append(", ");
                        }
                        stringBuilder.Append(parameters[j].GetType().ToString());
                    }
                }
                stringBuilder.Append(")");
                if (!string.IsNullOrEmpty(stackFrame.GetFileName()))
                {
                    stringBuilder.AppendFormat(" at {0}({1})", stackFrame.GetFileName(), stackFrame.GetFileLineNumber());
                }
                Diagnostics.LogFormat diagnosticsLogFormat = this.DiagnosticsLogFormat;
                if (diagnosticsLogFormat != Diagnostics.LogFormat.Html)
                {
                    if (diagnosticsLogFormat == Diagnostics.LogFormat.Text)
                    {
                        this.outputDepugFileStreamWriter.WriteLine("               -  {0}", stringBuilder.ToString());
                    }
                }
                else
                {
                    this.outputDepugFileStreamWriter.WriteLine(stringBuilder.ToString());
                }
                i++;
            }
        }
Example #2
0
        private void Diagnostics_MessageLogged(Diagnostics.LogMessage message)
        {
            if (this.outputDepugFileStreamWriter == null)
            {
                return;
            }
            Diagnostics.LogFormat diagnosticsLogFormat = this.DiagnosticsLogFormat;
            if (diagnosticsLogFormat != Diagnostics.LogFormat.Html)
            {
                if (diagnosticsLogFormat == Diagnostics.LogFormat.Text)
                {
                    Diagnostics.LogType logType  = (Diagnostics.LogType)((long)message.Flags & (long)((ulong)-16777216));
                    Diagnostics.LogType logType2 = logType;
                    if (logType2 != Diagnostics.LogType.Message)
                    {
                        if (logType2 == Diagnostics.LogType.Warning)
                        {
                            this.outputDepugFileStreamWriter.Write("[W] ");
                            goto IL_140;
                        }
                        if (logType2 == Diagnostics.LogType.Error)
                        {
                            this.outputDepugFileStreamWriter.Write("[E] ");
                            goto IL_140;
                        }
                    }
                    this.outputDepugFileStreamWriter.Write("    ");
IL_140:
                    this.outputDepugFileStreamWriter.Write(DateTime.Now.ToString("HH:mm:ss:fff"));
                    this.outputDepugFileStreamWriter.Write("  ");
                    this.outputDepugFileStreamWriter.WriteLine(message.Message);
                    this.Diagnostics_OutputDebugStackTrace(message);
                    this.outputDepugFileStreamWriter.WriteLine();
                }
            }
            else
            {
                Diagnostics.LogType logType3 = (Diagnostics.LogType)((long)message.Flags & (long)((ulong)-16777216));
                this.outputDepugFileStreamWriter.WriteLine("<p class=\"{1}\"><span class=\"time\">{2}</span><a onclick=\"hide('trace{0}')\">STACK</a>{3}</p>", new object[]
                {
                    this.DiagnosticsLogCounter,
                    logType3.ToString(),
                    DateTime.Now.ToString("HH:mm:ss:fff"),
                    message.Message
                });
                this.outputDepugFileStreamWriter.WriteLine("<pre id=\"trace{0}\">", this.DiagnosticsLogCounter);
                this.Diagnostics_OutputDebugStackTrace(message);
                this.DiagnosticsLogCounter++;
                this.outputDepugFileStreamWriter.WriteLine("</pre>");
            }
            this.outputDepugFileStreamWriter.Flush();
        }
Example #3
0
 private void Diagnostics_AssertionFailed(Diagnostics.LogMessage message)
 {
     if (this.outputDepugFileStreamWriter == null)
     {
         return;
     }
     Diagnostics.LogFormat diagnosticsLogFormat = this.DiagnosticsLogFormat;
     if (diagnosticsLogFormat != Diagnostics.LogFormat.Html)
     {
         if (diagnosticsLogFormat == Diagnostics.LogFormat.Text)
         {
             this.outputDepugFileStreamWriter.Write("[A] ");
             this.outputDepugFileStreamWriter.Write(DateTime.Now.ToString("HH:mm:ss:fff"));
             this.outputDepugFileStreamWriter.Write("  ");
             this.outputDepugFileStreamWriter.WriteLine(message.Message);
             this.Diagnostics_OutputDebugStackTrace(message);
             this.outputDepugFileStreamWriter.WriteLine();
         }
     }
     else
     {
         Diagnostics.LogType logType = Diagnostics.LogType.Assertion;
         this.outputDepugFileStreamWriter.WriteLine("<p class=\"{1}\"><span class=\"time\">{2}</span><a onclick=\"hide('trace{0}')\">STACK</a>{3}</p>", new object[]
         {
             this.DiagnosticsLogCounter,
             logType.ToString(),
             DateTime.Now.ToString("HH:mm:ss:fff"),
             "Assertion Failed: " + message.Message
         });
         this.outputDepugFileStreamWriter.WriteLine("<pre id=\"trace{0}\">", this.DiagnosticsLogCounter);
         this.Diagnostics_OutputDebugStackTrace(message);
         int diagnosticsLogCounter = this.DiagnosticsLogCounter;
         this.DiagnosticsLogCounter = diagnosticsLogCounter + 1;
         this.outputDepugFileStreamWriter.WriteLine("</pre>");
     }
     this.outputDepugFileStreamWriter.Flush();
 }