public void enqueue()

in sdk/appcenter/src/main/java/com/microsoft/appcenter/channel/DefaultChannel.java [609:706]


    public void enqueue(@NonNull Log log, @NonNull final String groupName, int flags) {

        /* Check group name is registered. */
        GroupState groupState = mGroupStates.get(groupName);
        if (groupState == null) {
            AppCenterLog.error(LOG_TAG, "Invalid group name:" + groupName);
            return;
        }

        /* Check if disabled with discarding logs. */
        if (mDiscardLogs) {
            AppCenterLog.warn(LOG_TAG, "Channel is disabled, the log is discarded.");
            if (groupState.mListener != null) {
                groupState.mListener.onBeforeSending(log);
                groupState.mListener.onFailure(log, new CancellationException());
            }
            return;
        }

        /* Call listeners so that they can decorate the log. */
        for (Listener listener : mListeners) {
            listener.onPreparingLog(log, groupName);
        }

        /* Attach device properties to every log if its not already attached by a service. */
        if (log.getDevice() == null) {

            /* Generate device properties only once per process life time. */
            if (mDevice == null) {
                try {
                    mDevice = DeviceInfoHelper.getDeviceInfo(mContext);
                } catch (DeviceInfoHelper.DeviceInfoException e) {
                    AppCenterLog.error(LOG_TAG, "Device log cannot be generated", e);
                    return;
                }
            }

            /* Attach device properties. */
            log.setDevice(mDevice);
        }

        /* Set date to current if not explicitly set in the past by a module (such as a crash). */
        if (log.getTimestamp() == null) {
            log.setTimestamp(new Date());
        }

        /* Notify listeners that log is prepared and is in a final state. */
        for (Listener listener : mListeners) {
            listener.onPreparedLog(log, groupName, flags);
        }

        /* Call listeners so that they can filter the log. */
        boolean filteredOut = false;
        for (Listener listener : mListeners) {
            filteredOut = filteredOut || listener.shouldFilter(log);
        }

        /* If filtered out, nothing more to do. */
        if (filteredOut) {
            AppCenterLog.debug(LOG_TAG, "Log of type '" + log.getType() + "' was filtered out by listener(s)");
        } else {
            if (mAppSecret == null && groupState.mIngestion == mIngestion) {

                /* Log was not filtered out but no app secret has been provided. Do nothing in this case. */
                AppCenterLog.debug(LOG_TAG, "Log of type '" + log.getType() + "' was not filtered out by listener(s) but no app secret was provided. Not persisting/sending the log.");
                return;
            }
            try {

                /* Persist log. */
                mPersistence.putLog(log, groupName, flags);
            } catch (Persistence.PersistenceException e) {
                AppCenterLog.error(LOG_TAG, "Error persisting log", e);
                if (groupState.mListener != null) {
                    groupState.mListener.onBeforeSending(log);
                    groupState.mListener.onFailure(log, e);
                }
                return;
            }

            /* Nothing more to do if the log is from a paused transmission target. */
            Iterator<String> targetKeys = log.getTransmissionTargetTokens().iterator();
            String targetKey = targetKeys.hasNext() ? PartAUtils.getTargetKey(targetKeys.next()) : null;
            if (groupState.mPausedTargetKeys.contains(targetKey)) {
                AppCenterLog.debug(LOG_TAG, "Transmission target ikey=" + targetKey + " is paused.");
                return;
            }

            /* Increment counters and schedule ingestion if we are enabled. */
            groupState.mPendingLogCount++;
            AppCenterLog.debug(LOG_TAG, "enqueue(" + groupState.mName + ") pendingLogCount=" + groupState.mPendingLogCount);
            if (mEnabled) {
                checkPendingLogs(groupState);
            } else {
                AppCenterLog.debug(LOG_TAG, "Channel is temporarily disabled, log was saved to disk.");
            }
        }
    }