Ejemplo n.º 1
0
        public bool Filter(ToastLoggerLogObject logData)
        {
            if (ToastLoggerSettings.Instance.isLogDuplicateFilter == false)
            {
                return(true);
            }

            long currentTime = ToastUtil.GetEpochMilliSeconds();

            _compareDuplicateInfos.RemoveAll(info => info.CreateTime < (currentTime - ToastLoggerSettings.Instance.filterDuplicateLogExpiredTimeSeconds * 1000));

            ToastLoggerDuplicateInfo duplicateInfo = new ToastLoggerDuplicateInfo();

            duplicateInfo.SetLogData(logData);

            foreach (var item in _compareDuplicateInfos)
            {
                if (item.Key == duplicateInfo.Key)
                {
                    return(false);
                }
            }

            if (_compareDuplicateInfos.Count >= _capacity)
            {
                _compareDuplicateInfos.RemoveAt(0);
            }

            _compareDuplicateInfos.Add(duplicateInfo);

            return(true);
        }
Ejemplo n.º 2
0
 public void AddToastLoggerLogObject(ToastLoggerLogObject logObject)
 {
     if (loggerFilter.CheckFilters(logObject) == true)
     {
         _bulkLog.Add(logObject);
     }
 }
 public bool Filter(ToastLoggerLogObject logData)
 {
     if (ToastLoggerSettings.Instance.isLogLevelFilter == false)
     {
         return(true);
     }
     else
     {
         return(logData.GetLogLevel() >= ToastLoggerSettings.Instance.filterLogLevel);
     }
 }
        public void OnLogSave(ToastLoggerLogObject logObject)
        {
            LogEntry log = new LogEntry();

            log.LogType       = logObject.GetLoggerType();
            log.LogLevel      = logObject.GetLogLevel();
            log.Message       = logObject.GetLogMessage();
            log.TransactionId = logObject.GetTransactionId();
            log.CreateTime    = logObject.GetCreateTime();

            if (_listenerLogger != null)
            {
                _listenerLogger.OnSave(log);
            }
        }
        public void OnLogFilter(string filterName, ToastLoggerLogObject logObject)
        {
            LogEntry log = new LogEntry();

            log.LogType       = logObject.GetLoggerType();
            log.LogLevel      = logObject.GetLogLevel();
            log.Message       = logObject.GetLogMessage();
            log.TransactionId = logObject.GetTransactionId();
            log.CreateTime    = logObject.GetCreateTime();

            if (_listenerLogger != null)
            {
                _listenerLogger.OnFilter(log, LogFilter.FromName(filterName));
            }
        }
Ejemplo n.º 6
0
 public bool Filter(ToastLoggerLogObject logData)
 {
     if (ToastLoggerSettings.Instance.isCrash)
     {
         return(true);
     }
     else
     {
         if (logData.GetLoggerType().Equals(ToastLoggerType.CRASH))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
 public bool Filter(ToastLoggerLogObject logData)
 {
     if (ToastLoggerSettings.Instance.isSession)
     {
         return(true);
     }
     else
     {
         if (logData.GetLoggerType().Equals(ToastLoggerType.SESSION))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
 public bool Filter(ToastLoggerLogObject logData)
 {
     if (ToastLoggerSettings.Instance.isNormal)
     {
         return(true);
     }
     else
     {
         if (logData.GetLoggerType().Equals(ToastLoggerType.NORMAL))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
        public bool CheckFilters(ToastLoggerLogObject logObject)
        {
            string filterName = "";

            foreach (var pair in _filters)
            {
                if (!pair.Value.Filter(logObject))
                {
                    filterName = pair.Key;
                    if (ToastLoggerCommonLogic.IsLoggerListener)
                    {
                        CrashLoggerListenerReceiver.Instance.OnLogFilter(filterName, logObject);
                    }
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        public bool Filter(ToastLoggerLogObject logData)
        {
            if (ToastLoggerSettings.Instance.isLogTypeFilter == false)
            {
                return(true);
            }
            else
            {
                foreach (string logType in ToastLoggerSettings.Instance.filterLogTypes)
                {
                    string strLogType = logData.GetLoggerType();
                    if (strLogType.Equals(logType))
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
        public void OnLogSuccess(ToastLoggerLogObject logObject)
        {
            LogEntry log = new LogEntry();

            log.LogType       = logObject.GetLoggerType();
            log.LogLevel      = logObject.GetLogLevel();
            log.Message       = logObject.GetLogMessage();
            log.TransactionId = logObject.GetTransactionId();
            log.CreateTime    = logObject.GetCreateTime();

            if (log.LogType == ToastLoggerType.CRASH_FROM_UNITY)
            {
                InvokeCrashListener(true, log);
            }
            else
            {
                if (_listenerLogger != null)
                {
                    _listenerLogger.OnSuccess(log);
                }
            }
        }
        public void OnLogError(ToastLoggerLogObject logObject, string errorMessage)
        {
            LogEntry log = new LogEntry();

            log.LogType       = logObject.GetLoggerType();
            log.LogLevel      = logObject.GetLogLevel();
            log.Message       = logObject.GetLogMessage();
            log.TransactionId = logObject.GetTransactionId();
            log.CreateTime    = logObject.GetCreateTime();

            if (log.LogType == ToastLoggerType.CRASH_FROM_UNITY)
            {
                InvokeCrashListener(false, log);
            }
            else
            {
                if (_listenerLogger != null)
                {
                    _listenerLogger.OnError(log,
                                            string.IsNullOrEmpty(errorMessage) ? "Unknown error" : errorMessage);
                }
            }
        }
        private static void SetCommonData(ToastLoggerLogObject logObject, string loggerType)
        {
            logObject.Put(ToastLoggerFields.PROJECT_VERSION, Application.version);
            logObject.Put(ToastLoggerFields.DEVICE_ID, ToastDeviceInfo.GetDeviceUniqueIdentifier());
            logObject.Put(ToastLoggerFields.PLATFORM_NAME, ToastApplicationInfo.GetPlatformName());
            logObject.Put(ToastLoggerFields.LAUNCHED_ID, ToastApplicationInfo.GetLaunchedId());
            logObject.Put(ToastLoggerFields.SDK_VERSION, ToastApplicationInfo.GetSDKVersion());
            logObject.Put(ToastLoggerFields.SESSION_ID, ToastApplicationInfo.GetSessionId());

            foreach (var item in Fields)
            {
                logObject.SetUserField(item.Key, item.Value);
            }

            if (ToastLoggerType.SESSION == loggerType ||
                ToastLoggerType.CRASH == loggerType ||
                ToastLoggerType.HANDLED == loggerType ||
                ToastLoggerType.CRASH_FROM_INACTIVATED_STATE == loggerType ||
                ToastLoggerType.CRASH_FROM_UNITY == loggerType)
            {
                logObject.Put(ToastLoggerFields.DEVICE_MODEL, ToastApplicationInfo.GetDeviceModel());
                logObject.Put(ToastLoggerFields.COUNTRY_CODE, ToastApplicationInfo.GetCountryCode());
            }
        }
 public void Add(ToastLoggerLogObject logData)
 {
     _logDatas.Add(logData);
 }
 public void SetLogData(ToastLoggerLogObject log)
 {
     Key        = log.GetDuplicateJSONString();
     HashMd5    = Md5Sum(Key);
     CreateTime = log.GetCreateTime();
 }