コード例 #1
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      VerboseLogException(string message, Exception exception)
        {
            if (Conf.DebugMode != Conf.DebugState.Verbose)
            {
                return;
            }

            InternalNGDebug.LogException(message, exception);
        }
コード例 #2
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      VerboseLogException(string message, Exception exception, UnityEngine.Object context)
        {
            if (Conf.DebugMode != Conf.DebugState.Verbose)
            {
                return;
            }

            InternalNGDebug.LogException(message, exception, context);
        }
コード例 #3
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      VerboseLog(object message)
        {
            if (Conf.DebugMode != Conf.DebugState.Verbose)
            {
                return;
            }

            InternalNGDebug.Log(message);
        }
コード例 #4
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      VerboseLogException(Exception exception)
        {
            if (Conf.DebugMode != Conf.DebugState.Verbose)
            {
                return;
            }

            InternalNGDebug.LogException(exception);
        }
コード例 #5
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      VerboseLogFormat(string format, params object[] args)
        {
            if (Conf.DebugMode != Conf.DebugState.Verbose)
            {
                return;
            }

            InternalNGDebug.LogFormat(format, args);
        }
コード例 #6
0
        private static void     InitAssemblies()
        {
            // Look into editor assemblies.
#if NETFX_CORE
            var taskAssemblies = UWPFakeExtension.GetAssemblies();
            taskAssemblies.Wait();
            Assembly[] editorAssemblies = taskAssemblies.Result;
#else
            Assembly[] editorAssemblies = AppDomain.CurrentDomain.GetAssemblies();
#endif

            List <Assembly> assemblies = new List <Assembly>(editorAssemblies.Length + 1)
            {
                typeof(MonoBehaviour).Assembly()
            };
            List <Type[]> types = new List <Type[]>(editorAssemblies.Length + 1)
            {
                typeof(MonoBehaviour).Assembly().GetTypes()
            };
#if NETFX_CORE
            Assembly executingAssembly = typeof(MonoBehaviour).Assembly();
#else
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
#endif

            for (int i = 0; i < editorAssemblies.Length; i++)
            {
                if (editorAssemblies[i] == assemblies[0])
                {
                    continue;
                }

                try
                {
                    Type[] asmTypes = editorAssemblies[i].GetTypes();

                    assemblies.Add(editorAssemblies[i]);
                    types.Add(asmTypes);

                    if (editorAssemblies[i] == executingAssembly)
                    {
                        Utility.executingTypes = asmTypes;
                    }
                }
                catch (Exception ex)
                {
                    InternalNGDebug.LogFileException("Assembly " + editorAssemblies[i] + " failed.", ex);
                }
            }

            Utility.allAssemblies = assemblies.ToArray();
            Utility.allTypes      = types.ToArray();
        }
コード例 #7
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      LogFile(object log)
        {
            if (Conf.DebugMode == Conf.DebugState.None)
            {
                return;
            }

            if (InternalNGDebug.Platform == RuntimePlatform.WindowsEditor || InternalNGDebug.Platform == RuntimePlatform.OSXEditor || InternalNGDebug.Platform == RuntimePlatform.LinuxEditor)
            {
                InternalNGDebug.VerboseLog(log);

                if (log != null)
                {
                    try
                    {
                        InternalNGDebug.waitHandle.WaitOne();

                        int logHash = log.GetHashCode();
                        if (logHash != InternalNGDebug.lastLogHash)
                        {
                            InternalNGDebug.lastLogHash    = logHash;
                            InternalNGDebug.lastLogCounter = 0;
                            File.AppendAllText(InternalNGDebug.LogPath, log + Environment.NewLine);
                        }
                        else
                        {
                            ++InternalNGDebug.lastLogCounter;
                            if (InternalNGDebug.lastLogCounter <= 2)
                            {
                                File.AppendAllText(InternalNGDebug.LogPath, log + Environment.NewLine);
                            }
                            else if (InternalNGDebug.lastLogCounter == 3)
                            {
                                File.AppendAllText(InternalNGDebug.LogPath, "…" + Environment.NewLine);
                            }
                        }
                    }
                    finally
                    {
                        InternalNGDebug.waitHandle.Set();
                    }
                }
            }
            else
            {
                Debug.Log("[" + Constants.PackageTitle + "] " + log);
            }
        }
コード例 #8
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      LogFileException(string message, Exception exception)
        {
            if (Conf.DebugMode == Conf.DebugState.None)
            {
                return;
            }

            if (InternalNGDebug.Platform == RuntimePlatform.WindowsEditor || InternalNGDebug.Platform == RuntimePlatform.OSXEditor || InternalNGDebug.Platform == RuntimePlatform.LinuxEditor)
            {
                InternalNGDebug.VerboseLog(message);
                InternalNGDebug.VerboseLogException(exception);

                try
                {
                    InternalNGDebug.waitHandle.WaitOne();

                    int logHash = message.GetHashCode() + exception.GetHashCode();
                    if (logHash != InternalNGDebug.lastLogHash)
                    {
                        InternalNGDebug.lastLogHash    = logHash;
                        InternalNGDebug.lastLogCounter = 0;
                        File.AppendAllText(InternalNGDebug.LogPath, message + Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine);
                    }
                    else
                    {
                        ++InternalNGDebug.lastLogCounter;
                        if (InternalNGDebug.lastLogCounter <= 2)
                        {
                            File.AppendAllText(InternalNGDebug.LogPath, message + Environment.NewLine + exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine);
                        }
                        else if (InternalNGDebug.lastLogCounter == 3)
                        {
                            File.AppendAllText(InternalNGDebug.LogPath, "…" + Environment.NewLine);
                        }
                    }
                }
                finally
                {
                    InternalNGDebug.waitHandle.Set();
                }
            }
            else
            {
                Debug.LogError("[" + Constants.PackageTitle + "] " + message);
                Debug.LogError("[" + Constants.PackageTitle + "] " + exception.Message + Environment.NewLine + exception.StackTrace);
            }
        }
コード例 #9
0
ファイル: InternalNGDebug.cs プロジェクト: Hengle/clapotis
        public static void      AssertFile(bool assertion, object message)
        {
            if (Conf.DebugMode == Conf.DebugState.None)
            {
                return;
            }

            if (assertion == false)
            {
                if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
                {
                    InternalNGDebug.VerboseError((message ?? "NULL").ToString());
                    InternalNGDebug.LogFile((message ?? "NULL").ToString());
                }
                else
                {
                    Debug.LogError("[" + Constants.PackageTitle + "] " + (message ?? "NULL").ToString());
                }
            }
        }
コード例 #10
0
        public void     Dispose()
        {
            SafeUnwrapByteBuffer.pool.Push(this);

            if (this.buffer.Position != fallbackEndPosition)
            {
                if (Conf.DebugMode >= Conf.DebugState.Active)
                {
                    SafeUnwrapByteBuffer.dumps.Add(new UnwrapDump()
                    {
                        error    = this.getMessage(),
                        start    = this.fallbackEndPosition - this.chunkFieldLength - sizeof(Int32),
                        position = this.buffer.Position,
                        end      = this.fallbackEndPosition,
                        buffer   = buffer.GetRawBuffer()
                    });
                }

                InternalNGDebug.LogError(this.getMessage() + ": Start " + (this.fallbackEndPosition - this.chunkFieldLength) + " > Pos " + this.buffer.Position + " > End " + this.fallbackEndPosition + ".");
                this.buffer.Position = fallbackEndPosition;
            }
        }