BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Empty logs #39

Open betterapp opened 2 years ago

betterapp commented 2 years ago

Under Result callback function I have code like this:

$params['transfer']->logs[] = $params['logs'];

if ($params['lastCall']) { var_dump($params['transfer']->logs); die; ..... }

Why $params['logs'] is empty ? We use 3.0.6 and in 2.8.6 it was not empty.

BlackbitDevs commented 2 years ago

Is this an import or an export? Or on other words: Does the dataport have a target class or does it have target class Export?

Background: Only object-specific logs will go to $params['logs']. Object-independent logs like general information cannot be accessed via $params['logs'] but it can via $params['context']['logs'].

betterapp commented 2 years ago

Import 0bjects

betterapp commented 2 years ago

but it worked in 2.8.*

BlackbitDevs commented 2 years ago

And you see logs when you click Finished successfully in the history panel?

betterapp commented 2 years ago

In history panel - log file - Yes

but

$params['logs'] is empty

betterapp commented 2 years ago

hmmm. now after rerun I see logs. strange.

betterapp commented 2 years ago

Hi. The problem happend sometimes.

I have code like this:

if (!function_exists('ConverrLocalDumpTransfer')) {
    function ConverrLocalDumpTransfer($transfer) { 

        if (empty($transfer)) {
            return '';
        }

        $fullLog = 'ImportId: ' . $transfer->runId . "\n";

        foreach ($transfer->logs as $log) {
            $itemStart = $itemEnd = '';
            if (isset($log['info'])) {
                $itemStart = $log['info'][0] . "\n";
                $itemEnd = end($log['info']) . "\n";
            }

            $warningText = '';
            if (isset($log['warning'])) {
                foreach ($log['warning'] as $warning) {
                    $warningText = $warningText . $warning . "\n";
                }
            }

            $noticeText = '';
            if (isset($log['notice'])) {
                foreach ($log['notice'] as $notice) {
                    $noticeText = $noticeText . $notice . "\n";
                }
            }

            $alertText = '';
            if (isset($log['alert'])) {
                foreach ($log['alert'] as $alert) {
                    $alertText = $alertText . $alert . "\n";
                }
            }

            $errorText = '';
            if (isset($log['error'])) {
                foreach ($log['error'] as $error) {
                    $errorText = $errorText . $error . "\n";
                }
            }

            $itemText = $itemStart . $errorText . $alertText . $warningText . $noticeText . $itemEnd;
            $fullLog .= $itemText . "\n";
        }

        $fullLog .= 'Import DONE ';

        $with = [];
        if (!empty($errorText)) {
            $with[] = 'errors';
        }
        if (!empty($alertText)) {
            $with[] = 'alerts';
        }
        if (!empty($noticeText)) {
            $with[] = 'notices';
        }
        if (!empty($warningText)) {
            $with[] = 'warnings';
        }

        if (!empty($with)) {
            $fullLog .= implode(', ', $with);    
        }

        return $fullLog . "\n";
    }
}

if (!isset($params['transfer']->runId)) {
  $params['transfer']->runId = uniqid();
}
$params['transfer']->logs[] = $params['logs'];

if ($params['lastCall']) {
          $supplierLog = ConverrLocalDumpTransfer($params['transfer']);
          if (!empty($supplierLog)) {

              $logFileName = $fileName . '-' . $params['transfer']->runId . '-import_log.txt';
              $logFile = new \Pimcore\Model\Asset();
              $logFile->setData($supplierLog);
              $logFile->save();
          }
}

And in some cases the log file is empty but for most 99% of imported files I have data in custom log.

In my case one file create such custom log file:

image

but orginal import log file have data: image

Is it possible that in some cases $params['logs'] will be empty ?

betterapp commented 1 year ago

any update ?