Exemplo n.º 1
0
        static public string Get(int type)
        {
            if (type >= 0 && type < LuaValueType.Max)
            {
                return(names[type]);
            }

            return("UnKnownType:" + ConstStringTable.GetNumIntern(type));
        }
Exemplo n.º 2
0
    private static void DoLog(LogLevel logLevel, string msg)
    {
        if (IsLogLevelEnabled(logLevel))
        {
            bd.Remove(0, bd.Length);
            DateTime now = DateTime.Now;
            bd.Append("[");
            bd.Append(ConstStringTable.GetTimeIntern(now.Hour)).Append(":");
            bd.Append(ConstStringTable.GetTimeIntern(now.Minute)).Append(":");
            bd.Append(ConstStringTable.GetTimeIntern(now.Second)).Append("-");
            bd.Append(now.Millisecond).Append("][");
            if (Thread.CurrentThread.ManagedThreadId == MainThreadID)
            {
                bd.Append(Time.frameCount);
            }
            else
            {
                bd.Append("0");
            }
            bd.Append("]").Append(_logPre[(int)logLevel]).Append(msg);
            string text = bd.ToString();
            switch (logLevel)
            {
            case LogLevel.Log:
                UnityEngine.Debug.Log((object)text);
                break;

            case LogLevel.Warning:
                UnityEngine.Debug.LogWarning((object)text);
                break;

            case LogLevel.Error:
                UnityEngine.Debug.LogError((object)text);
                break;

            case LogLevel.Exception:
                UnityEngine.Debug.LogError((object)text);
                break;
            }
            if (sm_logFileWriteStream != null)
            {
                sm_logFileWriteStream.WriteLine(text);
                sm_logFileWriteStream.Flush();
            }
        }
    }
Exemplo n.º 3
0
        private static string GetLogFormat(string str)
        {
            DateTime now = DateTime.Now;

            sb.Clear();
            sb.Append(ConstStringTable.GetTimeIntern(now.Hour)).Append(":").Append(ConstStringTable.GetTimeIntern(now.Minute))
            .Append(":")
            .Append(ConstStringTable.GetTimeIntern(now.Second))
            .Append(".")
            .Append(now.Millisecond)
            .Append("-")
            .Append(Time.frameCount % 999)
            .Append(": ")
            .Append(str);
            string text = StringPool.Alloc(sb.Length);

            sb.CopyToString(text);
            return(text);
        }
Exemplo n.º 4
0
        //减少gc alloc
        static string GetLogFormat(string str)
        {
            DateTime time = DateTime.Now;

            //StringBuilder sb = StringBuilderCache.Acquire();

            //sb.Append(ConstStringTable.GetTimeIntern(time.Hour))
            //    .Append(":")
            //    .Append(ConstStringTable.GetTimeIntern(time.Minute))
            //    .Append(":")
            //    .Append(ConstStringTable.GetTimeIntern(time.Second))
            //    .Append(".")
            //    .Append(time.Millisecond)
            //    .Append("-")
            //    .Append(Time.frameCount % 999)
            //    .Append(": ")
            //    .Append(str);

            //return StringBuilderCache.GetStringAndRelease(sb);

            sb.Clear();
            sb.Append(ConstStringTable.GetTimeIntern(time.Hour))
            .Append(":")
            .Append(ConstStringTable.GetTimeIntern(time.Minute))
            .Append(":")
            .Append(ConstStringTable.GetTimeIntern(time.Second))
            .Append(".")
            .Append(time.Millisecond)
            .Append("-")
            .Append(Time.frameCount % 999)
            .Append(": ")
            .Append(str);

            String dest = StringPool.Alloc(sb.Length);

            sb.CopyToString(dest);
            return(dest);
        }