Exemplo n.º 1
0
        public static List <TsLog.LogData.StackInfo> CreateStackInfo(string fullStack)
        {
            List <TsLog.LogData.StackInfo> list = new List <TsLog.LogData.StackInfo>();

            if (!string.IsNullOrEmpty(fullStack))
            {
                string[] array      = fullStack.Split(TsLog.LogData.SEP, StringSplitOptions.None);
                string   text       = string.Empty;
                string   methodName = string.Empty;
                string   text2      = string.Empty;
                string   text3      = string.Empty;
                for (int i = 0; i < array.Length; i++)
                {
                    text = array[i];
                    if (!text.Contains("Debug:Log") && !text.Contains("TsLog:Log") && !text.Contains("TsLog:Ass") && !text.Contains("TsLog:Exc"))
                    {
                        int num = text.LastIndexOf(TsLog.LogData.FileName_Sep1);
                        if (num != -1)
                        {
                            methodName = text.Substring(0, num);
                            text2      = text.Substring(num + TsLog.LogData.FileName_Sep1.Length);
                            num        = text2.LastIndexOf(TsLog.LogData.FileName_Sep2);
                            if (num != -1)
                            {
                                text3 = text2.Substring(num + TsLog.LogData.FileName_Sep2.Length);
                                text3 = text3.Remove(text3.Length - 1, 1);
                                int lineNum;
                                if (int.TryParse(text3, out lineNum))
                                {
                                    text2 = text2.Remove(num + 1);
                                    TsLog.LogData.StackInfo item = new TsLog.LogData.StackInfo(text2, methodName, lineNum);
                                    list.Add(item);
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
    public static void Assert(bool condition)
    {
        if (condition)
        {
            return;
        }
        if (!TsLog.EnableLogType(TsLog.ELogType.Assert))
        {
            return;
        }
        string fullStack = StackTraceUtility.ExtractStackTrace();
        List <TsLog.LogData.StackInfo> list = TsLog.LogData.CreateStackInfo(fullStack);

        if (list.Count <= 0)
        {
            return;
        }
        TsLog.LogData.StackInfo stackInfo = list[0];
        string text = string.Format("Assert~! {0}  [ {1} : {2} ]", stackInfo.methodName, stackInfo.fileName, stackInfo.lineNum);

        Debug.LogError(text);
        TsLog.Instance._assertLog.Add(text);
    }