Beispiel #1
0
 public ConfigsReader GetConfigsReader()
 {
     if (_configsReader == null)
     {
         _configsReader = new ConfigsReader(configs);
     }
     return(_configsReader);
 }
Beispiel #2
0
 public override void OnInitialize(ConfigsReader configs)
 {
     base.OnInitialize(configs);
     if (configs.Has("layout"))
     {
         var dict = configs.GetConfigs("layout");
         _layout = new Layout(dict);
     }
     else
     {
         _layout = new Layout();
     }
 }
Beispiel #3
0
        public override void OnInitialize(ConfigsReader configs)
        {
            base.OnInitialize(configs);
            var appenderNames = configs.GetStringArray("appenders", null);

            if (appenderNames != null)
            {
                foreach (var name in appenderNames)
                {
                    var appender = AppendersManager.GetAppender(name);
                    if (appender != null)
                    {
                        _redirectAppenders.Add(appender);
                    }
                }
            }
            var catagory = configs.GetString("catagory", null);

            if (catagory != null)
            {
                _catagoryRegex = new Regex(catagory);
            }
        }
Beispiel #4
0
        public virtual void OnInitialize(ConfigsReader configs)
        {
            var envStr = configs.GetString("env", null);

            if (envStr == null)
            {
                this.env = Env.All;
            }
            else
            {
                Env ret;
                if (System.Enum.TryParse <Env>(envStr, true, out ret))
                {
                    this.env = ret;
                }
                else
                {
                    Debug.LogWarning($"failed to parse {envStr} to Env");
                    this.env = Env.All;
                }
            }
            this.logLevel = Configurator.ParseLogLevel(configs.GetString("level", null));
        }
Beispiel #5
0
        public override void OnInitialize(ConfigsReader configs)
        {
            base.OnInitialize(configs);
            string fileName = configs.GetString("fileName", null);

            if (fileName == null)
            {
                fileName = FILE_NAME;
            }
            if (Path.IsPathRooted(fileName))
            {
                //absolute path
                this._filePath = fileName;
            }
            else
            {
                //relative path
                #if UNITY_EDITOR
                this._filePath = fileName;
                #else
                this._filePath = Path.Combine(Application.persistentDataPath, fileName);
                #endif
            }
            this._maxFileCount        = Mathf.Max(1, configs.GetInt("maxBackups", DEFAULT_MAX_BACK_UPS));
            this._maxFileSize         = Mathf.Max(10 * 1024, configs.GetInt("maxFileSize", DEFAULT_MAX_FILE_SIZE));
            _flushIntervalMillSeconds = Mathf.Max(0, configs.GetInt("flushInterval", 1000));
            bool keepExt = configs.GetBool("keepExt", DEFAULT_KEEP_EXT);

            RollType rollType    = RollType.Session;
            var      rollTypeStr = configs.GetString("rollType", null);
            if (rollTypeStr != null)
            {
                if (!System.Enum.TryParse <RollType>(rollTypeStr, out rollType))
                {
                    UnityEngine.Debug.LogWarning($"bad rollType:{rollTypeStr}");
                    rollType = RollType.Session;
                }
            }
            AppTrack.handleAppEvent += HandleAppEvent;
            if (rollType == RollType.Session)
            {
                _rollingFS = new IndexedRollingFileStream(_filePath, new IndexedRollingFileStream.Options()
                {
                    maxFileSize = _maxFileSize,
                    maxBackups  = _maxFileCount,
                    keepExts    = keepExt
                });
                _rollingFS.Roll();
            }
            else if (rollType == RollType.Date)
            {
                _rollingFS = new DateRollingFileStream(_filePath, new DateRollingFileStream.Options()
                {
                    maxBackups  = _maxFileCount,
                    maxFileSize = _maxFileSize,
                    keepExt     = keepExt
                });
            }
            else if (rollType == RollType.Size)
            {
                _rollingFS = new IndexedRollingFileStream(_filePath, new IndexedRollingFileStream.Options()
                {
                    maxFileSize = _maxFileSize,
                    maxBackups  = _maxFileCount,
                    keepExts    = keepExt
                });
            }
        }
Beispiel #6
0
 public Layout(ConfigsReader configs)
 {
     this.type    = configs.GetString("type", "basic");
     this.pattern = configs.GetString("pattern", null);
 }