• LogManager


    public class LogManager
    {
        // Fields
        public static bool Debugstate;
    
        // Methods
        public static void Log(string strText)
        {
            if (Debugstate)
            {
                Debug.Log(strText);
            }
        }
    
        public static void Log(string strText, Object context)
        {
            if (Debugstate)
            {
                Debug.Log(strText, context);
            }
        }
    
        public static void LogError(string strText)
        {
            if (Debugstate)
            {
                Debug.LogError(strText);
            }
        }
    
        public static void LogError(string strText, Object context)
        {
            if (Debugstate)
            {
                Debug.LogError(strText, context);
            }
        }
    
        public static void LogWarning(string strText)
        {
            if (Debugstate)
            {
                Debug.LogWarning(strText);
            }
        }
    
        public static void LogWarning(string strText, Object context)
        {
            if (Debugstate)
            {
                Debug.LogWarning(strText, context);
            }
        }
    }
    
     
    namespace Kola
    {
        using System;
        using System.IO;
        using System.Text;
        using UnityEngine;
    
        public class KDebugHelp
        {
            public static bool Enable;
            public static bool EnableKConsole;
    
            internal KDebugHelp()
            {
            }
    
            public static void Assert(bool flag, string format, params object[] param)
            {
                if (!flag)
                {
                    PrintError(format, param);
                }
            }
    
            public static void DrawCenterRect(Vector2 center, Vector2 size, float duration, Color color)
            {
                Vector2 leftTop = new Vector2(center.x - (size.x * 0.5f), center.y + (size.y * 0.5f));
                Vector2 rightBottom = new Vector2(center.x + (size.x * 0.5f), center.y - (size.y * 0.5f));
                DrawRect(leftTop, rightBottom, duration, color);
            }
    
            public static void DrawLine(Vector2 start, Vector2 end, float duration, Color color)
            {
                if (Enable)
                {
                    Debug.DrawLine((Vector3) start, (Vector3) end, color, duration);
                }
            }
    
            public static void DrawPolygon(float duration, Color color, bool close, params Vector2[] pnts)
            {
                if (Enable && ((pnts != null) && (pnts.Length > 1)))
                {
                    for (int i = 1; i < pnts.Length; i++)
                    {
                        DrawLine(pnts[i - 1], pnts[i], duration, color);
                    }
                    if (close)
                    {
                        DrawLine(pnts[pnts.Length - 1], pnts[0], duration, color);
                    }
                }
            }
    
            public static void DrawRect(Vector2 leftTop, Vector2 rightBottom, float duration, Color color)
            {
                if (Enable)
                {
                    DrawLine(new Vector3(leftTop.x, leftTop.y, 0f), new Vector3(rightBottom.x, leftTop.y, 0f), duration, color);
                    DrawLine(new Vector3(leftTop.x, rightBottom.y, 0f), new Vector3(rightBottom.x, rightBottom.y, 0f), duration, color);
                    DrawLine(new Vector3(leftTop.x, leftTop.y, 0f), new Vector3(leftTop.x, rightBottom.y, 0f), duration, color);
                    DrawLine(new Vector3(rightBottom.x, leftTop.y, 0f), new Vector3(rightBottom.x, rightBottom.y, 0f), duration, color);
                }
            }
    
            public static void Error(string msg)
            {
                WriteLog2File("Error", msg);
                if (Enable)
                {
                    if (EnableKConsole)
                    {
                    }
                    Debug.LogError(msg);
                }
            }
    
            public static void Error(string format, params object[] param)
            {
                Error(string.Format(format, param));
            }
    
            public static void Log(string msg)
            {
                if (Enable && !EnableKConsole)
                {
                    Debug.Log(msg);
                }
            }
    
            public static void Log(string format, params object[] param)
            {
                Log(string.Format(format, param));
            }
    
            public static void Print(string format, params object[] param)
            {
                Log(format, param);
            }
    
            public static void PrintError(string format, params object[] param)
            {
                Error(format, param);
            }
    
            public static void PrintWarning(string format, params object[] param)
            {
                Warning(format, param);
            }
    
            public static void Warning(string msg)
            {
                if (Enable)
                {
                    if (EnableKConsole)
                    {
                    }
                    Debug.LogWarning(msg);
                }
            }
    
            public static void Warning(string format, params object[] param)
            {
                Warning(string.Format(format, param));
            }
    
            public static void WriteLog2File(string level, string msg)
            {
                using (FileStream stream = new FileStream(KAssertManager.ExternalPath + "Log.txt", FileMode.Append))
                {
                    string s = string.Format("[{0}] [{1}] [{2}] 
    ", level, KUtil.GetSystemTime("HH:mm:ss"), msg);
                    byte[] bytes = Encoding.UTF8.GetBytes(s);
                    stream.Write(bytes, 0, bytes.Length);
                    stream.Flush();
                }
            }
        }
    }
  • 相关阅读:
    Write File in Vugen
    2016.5.15 随笔————查看class 的 Jad 反编译插件安装
    2016.5.15 随笔————Tomcat 配置文件 server.xml
    2016.5.10 随笔——Jmeter架入 java中使用 说明
    2016.5.10 随笔——SQL语句
    怎么和小孩一起玩--科学之旅:给孩子一场纯粹的玩耍(图)
    三味书屋 bbb
    亚信数据的组织结构
    深度学习的几个关键点
    数据可视化产品
  • 原文地址:https://www.cnblogs.com/123ing/p/3951582.html
Copyright © 2020-2023  润新知