2

I have enabled the profiler in order to find out which events are triggered during order creation and processing.

php bin/magento dev:profiler:enable csvfile

But it is alway overwriting

var/log/profiler.csv

On each request.

How can I keep all profiler output across requests?

2 Answers 2

1

If you need to output a request per file and you can not modify the vendor folder, you can extend in your own module the standard Csvfile class:

<?php
namespace Vendor\Module\Output;

class Csvfile extends \Magento\Framework\Profiler\Driver\Standard\Output\Csvfile
{
    /**
     * Parses file path
     *
     * @param array|null $config
     * @return string
     */
    protected function _parseFilePath(array $config = null)
    {
        $result = parent::_parseFilePath($config);
        return str_replace('.csv', "-".date('Ymd-His')."-".uniqid('', true).".csv", $result);
    }
}

Then you can launch the profiler with:

php bin\magento dev:profiler:enable "\\Vendor\\Module\\Output\\Csvfile"

Now the profiler will output each request in a different var/log/profile-yyyymmdd-hhmmss-rand.csv file.

2

A temporary are to change this is to edit this line:

vendor/magento/framework/Profiler/Driver/Standard/Output/Csvfile.php:41

To

public function __construct(array $config = null)
{
    parent::__construct($config);
    # change this line, append uniqid()
    $this->_filePath = $this->_parseFilePath($config) . uniqid('', true);
    $this->_delimiter = isset($config['delimiter']) ? $config['delimiter'] : ',';
    $this->_enclosure = isset($config['enclosure']) ? $config['enclosure'] : '"';
}

Of course this is a core patch and only for temporary use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.