Пример #1
0
        // 输出到控制台;
        private void Log(LogLevel outLevel, string info)
        {
            LogSetting set = LogSetManager.GetSetting(_name);

            // 当前输出级别 高于 日志级别 的才进行输出;
            if (outLevel >= set.LogLev)
            {
                // 添加标签信息;
                string logInfo = string.Format("[{0}]:{1}", _name, info);

                // 输出到控制台;
                switch (outLevel)
                {
                case LogLevel.DEBUG:
                case LogLevel.INFO:
                {
                    UnityEngine.Debug.Log(logInfo);
                } break;

                case LogLevel.WARN:
                {
                    UnityEngine.Debug.LogWarning(logInfo);
                } break;

                case LogLevel.ERROR:
                {
                    UnityEngine.Debug.LogError(logInfo);
                } break;

                default:
                {
                    // 异常;
                    UnityEngine.Debug.LogError(string.Format("日志输出异常; outLevel({0}) err; info:{1}", outLevel, logInfo));
                }
                break;
                }

                // 输出到文件;
                OutToFile(set.FilePath, logInfo);
            }
        }
Пример #2
0
 // 添加日志配置;
 public static void Add(string logKeyName, LogLevel logLevel, string filePath)
 {
     _settings[logKeyName] = new LogSetting(logLevel, filePath);
 }