Esempio n. 1
0
        private static void OnLogReceived(string condition, string stackTrace, LogType type)
        {
            int frameCount = ms_LastFrameCount;

            if (ThreadUtility.IsMainThread())
            {
                try
                {
                    frameCount = Time.frameCount;
                }
                catch (Exception)
                {
                    // get_frameCount is not allowed to be called during serialization, call it from OnEnable instead.
                    // 拿不到就不拿,不需要ErrorHandle
                }
                ms_LastFrameCount = frameCount;
            }

            MDebug.ParserLog(condition, out string tag, out string message);
            LogItem logItem = new LogItem(type, DateTime.Now, tag, message, stackTrace, frameCount);

            lock (ms_LockObject)
            {
                if (ms_EnableLogRecord)
                {
                    LogRecord._OnLogReceived(logItem);
                }

                if (ms_EnableLogItems)
                {
                    LogItems.GetInstance()._OnLogReceived(logItem);
                }
            }
        }
Esempio n. 2
0
        static LogReceiver()
        {
#if GF_DEBUG
            ms_EnableLogItems  = true;
            ms_EnableLogRecord = true;
#else
            ms_EnableLogItems  = false;
            ms_EnableLogRecord = false;
#endif

            // 这里是主线程。Unity的API不能在子线程里调用,所以需要提前在这里初始化LogRecord和LogItems
            if (ms_EnableLogRecord)
            {
                LogRecord._ForInItialize();
            }

            if (ms_EnableLogItems)
            {
                LogItems.GetInstance();
            }

            ms_LastFrameCount = Time.frameCount;
            ms_LockObject     = new object();

            Application.logMessageReceivedThreaded -= OnLogReceived;
            if (ms_EnableLogRecord ||
                ms_EnableLogItems)
            {
                ms_LastFrameCount = Time.frameCount;
                ms_LockObject     = new object();
                Application.logMessageReceivedThreaded += OnLogReceived;
            }
        }
Esempio n. 3
0
        public static LogItems GetInstance()
        {
            if (ms_Instance == null)
            {
                ms_Instance = new LogItems();
            }

            return(ms_Instance);
        }