Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The module logs index invalidations along with respective stacktrace in order to gain more knowledge about index invalidations that are triggered automatically.

Table of Contents

Installation

Info

This module is optional.

...

Index Invalidation Debugger Settings

Field

Optiona

Comment

Enable Logging

Yes/No 

Enables logging all index invalidation along with stacktraces.

Logging retention period

How long (in days) logs should be kept

The index logger link can be found in System -> Tools -> Index Management

...

Backend

AdminHtml - Index invalidation log action

vendor/creativestyle/magesuite-index-invalidation-logger/Controller/Adminhtml/Log/Index.php:7
Code Block
breakoutModewide
class Index extends \Magento\Backend\App\Action
{
    public function execute()
    {
        $resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
        $resultPage->getConfig()->getTitle()->set(__('Index invalidation log'));

        return $resultPage;
    }
}

Cron - cleanup logs

vendor/creativestyle/magesuite-index-invalidation-logger/Cron/LogsCleanup.php:26

Code Block
breakoutModewide
class LogsCleanup
{
    public function execute()
    {
        if (!$this->configuration->isLoggingEnabled()) {
            return;
        }

        $this->cleanLogs->execute($this->configuration->getLoggingRetentionPeriod());
    }
}

Command - cleanup logs

Is used by previous mentioned cron

vendor/creativestyle/magesuite-index-invalidation-logger/Model/Command/CleanLogs.php:17
Code Block
class CleanLogs
{
    public function execute($retentionPeriodInDays) {
        .....

        $logsTable = $this->connection->getTableName('index_invalidation_log');

        $this->connection->delete(
            $logsTable,
            "executed_at < date_sub(CURDATE(), INTERVAL ".$retentionPeriodInDays." Day)"
        );
    }
}

Adding $stackTraceId to InvalidationLog table

vendor/creativestyle/magesuite-index-invalidation-logger/Model/ResourceModel/InvalidationLog.php:28
Code Block
class InvalidationLog extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
    {
        $context = $object->getContext();
        ....
        $stackTraceId = $this->stacktraceResourceModel->getStackTraceId($stackTrace);
        .....
        $object->setContext(json_encode($context));
        $object->setStacktraceId($stackTraceId);

        return parent::_beforeSave($object);
    }
}

vendor/creativestyle/magesuite-index-invalidation-logger/Model/ResourceModel/InvalidationLogStacktrace.php:14
Code Block
class InvalidationLogStacktrace extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    public function getStackTraceId($stackTrace)
    {
        .....
        $stacktraceId = $this->getExistingStacktraceId($hash);
        .....
        $this->existingStackTracesIdsCache[$hash] = $stacktraceId;

        return $this->existingStackTracesIdsCache[$hash];
    }
}

Frontend

There are no frontend functionalities in the module.