public static StackInfo GetStackInfo(string stackLine)
        {
            StackInfo unknownVal = new StackInfo {
                dllName = "Unknown", className = String.Empty
            };
            StackInfo retVal = new StackInfo();

            try
            {
                if (stackLine.StartsWith("UnityEngine.") || stackLine.StartsWith("KSPAssets."))
                {
                    return(retVal);
                }

                if (classCache.ContainsKey(stackLine))
                {
                    return(classCache[stackLine]);
                }

                string processLine = null;
                try
                {
                    processLine = stackLine.Substring(0, stackLine.LastIndexOf(" ("));
                }
                catch (ArgumentOutOfRangeException oor)
                {
                }

                string methodName = processLine.Substring(processLine.LastIndexOf(".") + 1);
                processLine = processLine.Substring(0, processLine.Length - (methodName.Length + 1));
                if (processLine.Contains("["))
                {
                    processLine = processLine.Substring(0, processLine.IndexOf("["));
                }
                //UNITY WHY DO YOU HAVE TO BE SO BAD
                //Type foundType = Type.GetType(processLine);
                Type foundType = null;
                foreach (Assembly testAssembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (Type testType in testAssembly.GetExportedTypes())
                    {
                        if (testType.FullName == processLine)
                        {
                            foundType = testType;
                            break;
                        }
                    }
                    if (foundType != null)
                    {
                        break;
                    }
                }
                if (foundType != null)
                {
                    string dllPath = foundType.Assembly.Location;
                    retVal.dllName = Path.GetFileNameWithoutExtension(dllPath);
                    if (!dllPath.ToLower().Contains("gamedata"))
                    {
                        retVal.isMod = false;
                        if (retVal.dllName.ToLower() == "mscorelib")
                        {
                            retVal.dllName = "Mono";
                        }
                        if (unityDlls.Contains(retVal.dllName.ToLower()))
                        {
                            retVal.dllName = "Unity";
                        }
                        if (kspDlls.Contains(retVal.dllName.ToLower()))
                        {
                            retVal.dllName = "KSP";
                        }
                    }
                    retVal.namespaceName = foundType.Namespace;
                    retVal.className     = foundType.Name;
                    if (retVal.className.Contains("`"))
                    {
                        retVal.className = retVal.className.Substring(0, retVal.className.IndexOf("`"));
                    }
                    retVal.methodName = methodName;
                    classCache.Add(stackLine, retVal);
                    return(retVal);
                }


                if (unknownVal.className.Contains("`"))
                {
                    unknownVal.className = unknownVal.className.Substring(0, unknownVal.className.IndexOf("`"));
                }

                unknownVal.methodName = methodName;
                classCache.Add(stackLine, unknownVal);
            }catch (Exception ex)
            {
                retVal = unknownVal;
            }
            return(retVal);
        }
        public static void HandleLogEntry(string condition, string stackTrace, LogType logType)
        {
            //WriteLog("\n<<<<<<<< " + stackLogTick + "\t" + DoublePassValues.Count + "\t" + prvConditionStatement);
            string stkMsg     = String.Empty;
            bool   doublePass = CheckPass(condition, DoublePassValues);
            bool   singlePass = false;

            if (!doublePass)
            {
                singlePass = CheckPass(condition, SinglePassValues);
            }

            if (doublePass)
            {
                // WriteLog(stackTrace);
                // save it
                preStack = condition;
                if (logType != LogType.Log)
                {
                    AddException(CleanCondition(condition));
                }
                stackLogTick = 1;
                if (!HideKnowns)
                {
                    //WriteLog("hidingknowns\n");
                    logTheMessage(condition, stackTrace, logType);
                }
            }
            //else if (stackLogTick == 0 && !condition.Equals(prvConditionStatement))
            //{
            //	logTheMessage(condition, stackTrace, logType);
            //	WriteLog("\n");
            //}

            if (logType == LogType.Log && ShowInfoMessage)
            {
                logTheMessage(condition, stackTrace, logType);
            }
            else if (logType == LogType.Error || logType == LogType.Warning)
            {
                //WriteLog(logType.ToString() + " : " + stackLogTick + " : " + condition);
                if (stackLogTick == 1)
                {
                    prvConditionStatement = condition;

                    strMessage = "*EDU*\t" + preStack + "--> " + CleanCondition(condition) + "\n";
                    WriteLog(strMessage);
                    AddException(strMessage);
                    stackLogTick = 0;
                    preStack     = String.Empty;
                }
                else if (singlePass)
                {
                    WriteLog("*EDU*\t" + condition + "\n");
                    AddException(CleanCondition(condition));
                }
                else if (stackLogTick == 0 && !condition.Equals(prvConditionStatement))
                {
                    logTheMessage(condition, stackTrace, logType);
                    WriteLog(stackTrace);
                    WriteLog("\n");
                    AddException(CleanCondition(condition));
                }
            }
            else if (logType == LogType.Exception)
            {
                try
                {
                    stkMsg = stackTrace;
                    if (!String.IsNullOrEmpty(condition) && ExceptionCount.ContainsKey(CleanCondition(condition)) && ExceptionCount[CleanCondition(condition)] > 20)
                    {
                        ulong ct = ExceptionCount[CleanCondition(condition)];
                        stkMsg = "Exception has been called " + ++ct + " times";
                        ExceptionCount[CleanCondition(condition)] = ct;
                    }
                    else
                    {
                        AddException(CleanCondition(condition));
                    }
                    logTheMessage(condition, stkMsg, "**EDU-Exception");
                    WriteLog("EDU-EXCEPTION****\n\n\n");

                    //ExceptionDetectorUpdated.Instance.OnGUI();
                    using (StringReader sr = new StringReader(stackTrace))
                    {
                        StackInfo firstInfo   = null;
                        StackInfo stackInfo   = null;
                        bool      foundMod    = false;
                        string    currentLine = sr.ReadLine();
                        while (!foundMod && currentLine != null)
                        {
                            stackInfo = GetStackInfo(currentLine);
                            if (firstInfo == null)
                            {
                                firstInfo = stackInfo;
                            }
                            if (stackInfo.isMod)
                            {
                                //We found a mod in the trace, let's blame them.
                                foundMod = true;
                                break;
                            }
                            currentLine = sr.ReadLine();
                        }
                        if (!foundMod)
                        {
                            //If we didn't find a mod, blame the method that threw.
                            stackInfo = firstInfo;
                        }
                        if (!methodThrows.ContainsKey(stackInfo.dllName))
                        {
                            methodThrows.Add(stackInfo.dllName, new Dictionary <StackInfo, int>());
                        }
                        if (!methodThrows[stackInfo.dllName].ContainsKey(stackInfo))
                        {
                            methodThrows[stackInfo.dllName].Add(stackInfo, 0);
                        }
                        methodThrows[stackInfo.dllName][stackInfo]++;
                    }
                    throwTime.Enqueue(Time.realtimeSinceStartup);
                }
                catch (Exception ex)
                {
                    WriteLog(ex.ToString());
                }
            }

            //ExceptionDetectorUpdated.Instance.OnGUI();
            //WriteLog(">>>>>>>>\n");
        }