Skip to content

Export Logging #196

Closed
Closed
@svenkraenkel

Description

@svenkraenkel

By activating logging via
protected $_debugMode = true;
I will get the following error:
Tested with Magento 1.7.0.2 but the code in Magento 2 at this part is always the same:
Fatal error: Undefined class constant 'LOG_DIRECTORY' in /var/www/magento-1.7.0.2/app/code/core/Mage/ImportExport/Model/Abstract.php on line 93
by calling
Mage_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY.
Function in Magento2 (2.0.0.0-dev39):
/**

  • Log debug data to file.

  • Log file dir: var/log/import_export/%Y/%m/%d/%time%%operation_type%%entity_type%.log
    *

  • @param mixed $debugData

  • @return Mage_ImportExport_Model_Abstract
    */
    public function addLogComment($debugData)
    {
    if (is_array($debugData)) {
    $this->_logTrace = array_merge($this->_logTrace, $debugData);
    } else {
    $this->_logTrace[] = $debugData;
    }
    if (!$this->_debugMode) {
    return $this;
    }

    if (!$this->_logInstance) {
        $dirName = date('Y' . DS .'m' . DS .'d' . DS);
        $fileName = join('_', array(
            str_replace(':', '-', $this->getRunAt()),
            $this->getScheduledOperationId(),
            $this->getOperationType(),
            $this->getEntity()
        ));
        $dirPath = Mage::getBaseDir('var') . DS . Mage_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY
            . $dirName;
        if (!is_dir($dirPath)) {
            mkdir($dirPath, 0777, true);
        }
        $fileName = substr(strstr(Mage_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY, DS), 1)
            . $dirName . $fileName . '.log';
        $this->_logInstance = Mage::getModel('Mage_Core_Model_Log_Adapter', array('fileName' => $fileName))
            ->setFilterDataKeys($this->_debugReplacePrivateDataKeys);
    }
    $this->_logInstance->log($debugData);
    return $this;
    

    }
    Function in Magento 1.7.0.2 and 1.5:
    /**

    • Log debug data to file.

    • Log file dir: var/log/import_export/%Y/%m/%d/%time%%operation_type%%entity_type%.log
      *

    • @param mixed $debugData

    • @return Mage_ImportExport_Model_Abstract
      */
      public function addLogComment($debugData)
      {
      if (is_array($debugData)) {
      $this->_logTrace = array_merge($this->_logTrace, $debugData);
      } else {
      $this->_logTrace[] = $debugData;
      }
      if (!$this->_debugMode) {
      return $this;
      }

      if (!$this->logInstance) {
      $dirName = date('Y' . DS .'m' . DS .'d' . DS);
      $fileName = join('
      ', array(
      str_replace(':', '-', $this->getRunAt()),
      $this->getScheduledOperationId(),
      $this->getOperationType(),
      $this->getEntity()
      ));
      $dirPath = Mage::getBaseDir('var') . DS . Mage_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY
      . $dirName;
      if (!is_dir($dirPath)) {
      mkdir($dirPath, 0777, true);
      }
      $fileName = substr(strstr(Mage_ImportExport_Model_Scheduled_Operation::LOG_DIRECTORY, DS), 1)
      . $dirName . $fileName . '.log';
      $this->_logInstance = Mage::getModel('core/log_adapter', $fileName)
      ->setFilterDataKeys($this->_debugReplacePrivateDataKeys);
      }
      $this->_logInstance->log($debugData);
      return $this;
      }
      Is there an other way existing to set export logging to true outside the template?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions