Exemplo n.º 1
0
 public static void Log(string s, DebugLevels lev = DebugLevels.DEBUG)
 {
     if ((currentLevel == lev) || (lev == DebugLevels.ALWAYS))
     {
         Debug.Log(s);
     }
 }
Exemplo n.º 2
0
 public static void Debug(string cls, string msg, DebugLevels level)
 {
     Console.ForegroundColor = (ConsoleColor)level;
     Console.Write(cls);
     Console.ForegroundColor = ConsoleColor.White;
     Console.WriteLine(" | " + msg);
 }
 /// <summary>
 /// 创建应用程序实例
 /// </summary>
 /// <param name="debugLevel">调试等级</param>
 /// <returns>应用程序实例</returns>
 protected override Application CreateApplication(DebugLevels debugLevel)
 {
     return(new ILRuntimeApplication(this)
     {
         DebugLevel = debugLevel
     });
 }
 /// <summary>
 /// 创建新的Application实例
 /// </summary>
 /// <param name="debugLevel">调试等级</param>
 /// <returns>Application实例</returns>
 protected virtual Application CreateApplication(DebugLevels debugLevel)
 {
     return(new UnityApplication(this)
     {
         DebugLevel = DebugLevel
     });
 }
        /// <summary>
        /// 注册资源加载器
        /// </summary>
        /// <param name="debugLevel">调试等级</param>
        private void RegisterLoader(DebugLevels debugLevel)
        {
            var binder = SingletonLoaderWithDebugLevel(debugLevel) ?? SingletonLoaderWithPlatform();

            binder.OnResolving <ILoadingRule>(rule =>
            {
                rule.EnableSyncLoad = EnableSyncLoad;
            });
        }
Exemplo n.º 6
0
        static public void LogInfoIfDebugLevel(DebugLevels debugLevels, string txt)
        {
            bool hasFlag = (Globals.debugLevel & debugLevels) > 0;

            if (!hasFlag)
            {
                return;
            }
            Console.WriteLine(txt);
            Debug.WriteLine(txt);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 构造一个ILRuntime Appdomain
        /// </summary>
        /// <param name="application">应用程序</param>
        /// <param name="debugLevel">调试等级</param>
        public AppDomain(IApplication application, DebugLevels debugLevel)
        {
            Domain      = new ILRuntimeDomain();
            DebugLevel  = debugLevel;
            Application = application;
            inited      = false;

            RegisterDefaultDelegate();
            RegisterRedirect.Register(Domain);
            RegisterAdapter.Register(Domain);
        }
        /// <summary>
        /// 根据调试等级单例化指定的加载器
        /// </summary>
        /// <param name="debugLevel">调试等级</param>
        /// <returns>服务绑定数据</returns>
        private IBindData SingletonLoaderWithDebugLevel(DebugLevels debugLevel)
        {
            switch (debugLevel)
            {
            case DebugLevels.Development:
                return(SingletonLoaderAssetData());

            case DebugLevels.Staging:
                return(SingletonLoaderAssetBundle());
            }

            return(null);
        }
        /// <summary>
        /// 根据调试等级获取路径
        /// </summary>
        /// <param name="level">调试等级</param>
        /// <returns>路径</returns>
        private string GetPathWithDebugLevels(DebugLevels level)
        {
            switch (level)
            {
            case DebugLevels.Staging:
                return(Path.Combine(UnityEngine.Application.dataPath, "StreamingAssets"));

            case DebugLevels.Dev:
                return(UnityEngine.Application.dataPath);

            case DebugLevels.Prod:
                return(UnityEngine.Application.persistentDataPath);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Выводит в консоль строку отформатированную в соответствии с уровнем логирования
        /// </summary>
        /// <param name="text">Выводимая строка</param>
        /// <param name="level">Уровень логирования</param>
        public static void ConsoleWriteLine(string text, DebugLevels level)
        {
            if (level == DebugLevels.None)
            {
                return;
            }
            int lvl = (int)level;

            if (lvl != 1 && (lvl % 2) != 0)
            {
                throw new FormatException("Неверно задан параметр определяющий уровень логирования");
            }

            if (DebugLevel.HasFlag(level))
            {
                string fmt = string.Format("[{0}] {1}", Enum.GetName(typeof(DebugLevels), level), text);
                Console.WriteLine(fmt);
            }
        }
Exemplo n.º 11
0
        private void ShowLog(string log, DebugLevels debugLevel, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                prefix = "[" + prefix + "]";
            }

            string logContent = ComponentName + prefix + ": " + log;


            if (!IsDebugModeOn)
            {
                return;
            }

            switch (debugLevel)
            {
            case DebugLevels.Debug:
                UnityEngine.Debug.LogWarning("[DEBUG] " + logContent);
                break;

            case DebugLevels.Info:
                UnityEngine.Debug.Log(logContent);
                break;

            case DebugLevels.Warning:
                UnityEngine.Debug.LogWarning(logContent);
                break;

            case DebugLevels.Exception:
                UnityEngine.Debug.LogException(new Exception(logContent));
                break;

            case DebugLevels.Error:
                UnityEngine.Debug.LogError(logContent);
                break;

            case DebugLevels.Special:
                UnityEngine.Debug.LogError(logContent);
                break;
            }
        }
Exemplo n.º 12
0
        public static void Debug(string cls, string msg, DebugLevels level)
        {
            if ( UDProxy.lol )
            {
                if (fRand == null) fRand = new Random(69);
                if (fCols == null) fCols = Enum.GetValues(typeof(ConsoleColor));
                ConsoleColor color;

                do
                {
                    color = (ConsoleColor)fCols.GetValue(fRand.Next(fCols.Length));
                } while (color == ConsoleColor.DarkRed);

                Console.ForegroundColor = color;
                Console.WriteLine(cls + " | " + msg);
            }
            else
            {
                Console.ForegroundColor = (ConsoleColor)level;
                Console.Write(cls);
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(" | " + msg);
            }
        }
Exemplo n.º 13
0
        public static void Write(object formOrString, string message, DebugLevels level = DebugLevels.FATAL)
        {
            try
            {
                if (DebugLevel < (int)level)
                {
                    return;
                }

                string formName;
                if (formOrString is string)
                {
                    formName = formOrString.ToString();
                }
                else
                {
                    formName = formOrString.GetType().Name;
                }

                if (string.Empty != formName)
                {
                    formName += ";";
                }

                long maxMemory   = Java.Lang.Runtime.GetRuntime().MaxMemory();
                long freeMemory  = Java.Lang.Runtime.GetRuntime().FreeMemory();
                long totalMemory = Java.Lang.Runtime.GetRuntime().TotalMemory();

                string userName = string.Empty != Activities.LoginActivity.User ? Activities.LoginActivity.User : "******";

                string userTimeLevel = userName + ";" + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + ";" + formName + level + ";";
                string memoryInfo    = " Memory:Max=" + maxMemory + " Free=" + freeMemory + " Total=" + totalMemory + NewLine;

                string lineWS = userTimeLevel + message + memoryInfo;

                string retWSstatus = WriteToWS(AndroidId, lineWS);

                if (Utility.RET_STATUS_OK != retWSstatus)
                {
                    File.AppendAllText(Filename, lineWS);
                    File.AppendAllText(Filename, userTimeLevel + LogWriteErrorText + retWSstatus + NewLine);
                }
                else if (File.Exists(Filename))
                {
                    string[] lines = File.ReadAllLines(Filename);
                    File.Delete(Filename);
                    foreach (string line in lines)
                    {
                        string devId = AndroidId;
                        string msg   = line;

                        retWSstatus = WriteToWS(devId, msg);
                        if (Utility.RET_STATUS_OK != retWSstatus)
                        {
                            File.AppendAllText(Filename, line);
                            File.AppendAllText(Filename, userTimeLevel + LogWriteErrorText + retWSstatus + NewLine);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 设定调试等级
 /// </summary>
 /// <param name="level">调试等级</param>
 public static void SetDebugLevel(DebugLevels level)
 {
     Handler.SetDebugLevel(level);
 }
Exemplo n.º 15
0
 /// <summary>
 /// 设定调试等级
 /// </summary>
 /// <param name="level">调试等级</param>
 public void SetDebugLevel(DebugLevels level)
 {
     DebugLevel = level;
 }
Exemplo n.º 16
0
 /// <summary>
 /// 设定调试等级
 /// </summary>
 /// <param name="level">调试等级</param>
 public void SetDebugLevel(DebugLevels level)
 {
     Instance(Type2Service(typeof(DebugLevels)), level);
 }
Exemplo n.º 17
0
 public RocLog(string componentName, DebugLevels debugLevel)
 {
     ComponentName = componentName;
     DebugLevel    = debugLevel;
 }
Exemplo n.º 18
0
 /// <summary>
 /// 构造一个演示用的AppDomain
 /// </summary>
 /// <param name="application">应用程序</param>
 /// <param name="debugLevel">调试等级</param>
 public DemoAppDomain(IApplication application, DebugLevels debugLevel)
     : base(application, debugLevel)
 {
     Adapter.RegisterAdapter.Register(Domain);
     CLRBindings.Initialize(Domain);
 }
 /// <summary>
 /// Determines if the specified flag is present in the <see cref="DebugLevels"/> enumeration.
 /// </summary>
 /// <param name="levels">The object to check for flags.</param>
 /// <param name="flagToFind">The flag to look for.</param>
 /// <returns>A true or false value indicating the presence of the flag.</returns>
 public static bool Contains(this DebugLevels levels, DebugLevels flagToFind)
 {
     return((levels | flagToFind) == levels);
 }