Skip to content

Commit

Permalink
Added stack trace information
Browse files Browse the repository at this point in the history
Added stack trace information when LDTP_DEBUG_LEVEL set to 3

QA Notes:
Testing Done: Yes
Documentation Notes:
Bug Number:
Reviewed by:
Approved by:
Mailto:
  • Loading branch information
nagappan committed Mar 18, 2014
1 parent ef33a26 commit 3a912d3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Ldtpd/Common.cs
Expand Up @@ -28,6 +28,7 @@
using System;
using System.Threading;
using System.Collections;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace Ldtpd
Expand All @@ -36,6 +37,7 @@ public class Common
{
bool debug = false;
System.IO.StreamWriter sw;
StackTrace stackTrace = null;
System.IO.FileStream fs = null;
internal string writeToFile = null;

Expand All @@ -60,6 +62,12 @@ public Common(bool debug)
System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
sw = new System.IO.StreamWriter(fs);
}
if (debug || writeToFile != null)
{
string tmpDebug = Environment.GetEnvironmentVariable("LDTP_DEBUG_LEVEL");
if (tmpDebug != null && tmpDebug == "3")
stackTrace = new StackTrace(1, true);
}
}

~Common()
Expand Down Expand Up @@ -88,7 +96,8 @@ public void LogMessage(Object o)
{
if (debug)
{
Console.WriteLine(o);
string callerName = stackTrace == null ? "" : stackTrace.ToString();
Console.WriteLine("{0}:{1}", callerName, o);
try
{
if (logStack.Count == 1000)
Expand All @@ -106,8 +115,11 @@ public void LogMessage(Object o)
}
}
if (fs != null)
{
string callerName = stackTrace == null ? "" : stackTrace.ToString();
// Write content to log file
sw.WriteLine(o);
sw.WriteLine("{0}:{1}", callerName, o);
}
}
public bool WildcardMatch(string stringToSearch, string searchPhrase)
{
Expand Down

0 comments on commit 3a912d3

Please sign in to comment.