ecoco/magento_profiler

View on GitHub
app/design/frontend/base/default/template/ecocode_profiler/collector/log/panel/log-table.phtml

Summary

Maintainability
Test Coverage
<?php
/** @var Ecocode_Profiler_Block_Renderer_Log_LogTable $this */
$channelIsDefined = $this->isChannelDefined();
$showLevel        = $this->getShowLevel();
$isDeprecation    = $this->isDeprecation();

/** @var Ecocode_Profiler_Helper_Code $codeHelper */
$codeHelper = Mage::helper('ecocode_profiler/code');

/** @var Ecocode_Profiler_Helper_ValueExporter $valueExporter */
$valueExporter = Mage::helper('ecocode_profiler/valueExporter');

/** @var Ecocode_Profiler_Helper_Renderer $rendererHelper */
$rendererHelper = Mage::helper('ecocode_profiler/renderer');
?>
<table class="logs" xmlns="http://www.w3.org/1999/html">
    <thead>
    <tr>
        <th><?php echo $showLevel ? 'Level' : 'Time' ?></th>
        <?php echo $channelIsDefined ? '<th>Channel</th>' : '' ?>
        <th style="width: 100%">Message</th>
    </tr>
    </thead>

    <tbody>
    <?php foreach ($this->getLogs() as $index => $log): ?>
        <?php
        $cssClass = '';
        if (!$isDeprecation) {
            switch ($log['priorityName']) {
                case 'CRITICAL':
                case 'ERROR':
                case 'ALERT':
                case 'EMERGENCY':
                    $cssClass = 'status-error';
                    break;
                case 'WARNING':
                case 'NOTICE':
                    $cssClass = 'status-warning';

            }
        }
        ?>
        <tr class="<?php echo $cssClass ?>">
            <td class="font-normal text-small">
                <?php if ($showLevel): ?>
                    <span class="colored text-bold nowrap"><?php echo $log['priorityName'] ?></span>
                <?php endif ?>
                <span class="text-muted nowrap newline"><?php echo date('H:i:s', $log['timestamp']) ?></span>
            </td>

            <?php if ($channelIsDefined): ?>
                <td class="font-normal text-small text-bold nowrap"><?php echo $log['channel'] ?></td>
            <?php endif; ?>

            <td class="font-normal">
                <?php echo $log['message']; ?>

                <?php if ($this->isDeprecation()): ?>
                    <?php $stack = isset($log['context']['stack']) ? $log['context']['stack'] : []; ?>
                    <?php array_shift($stack); //remove the error handler from stack ?>
                    <?php $stackId = $this->getCategory() . '-' . $index; ?>

                    <?php if (isset($log['context']['errorCount'])): ?>
                        <span class="text-small text-bold">(<?php echo $log['context']['errorCount'] ?> times)</span>
                    <?php endif; ?>

                    <?php if ($stack): ?>
                        <button class="btn-link text-small sf-toggle" data-toggle-selector="#stack-<?php echo $stackId ?>"
                                data-toggle-alt-content="Hide stack trace">Show stack trace
                        </button>
                        <?php echo $rendererHelper->renderCallStack($stackId, $stack) ?>
                    <?php endif; ?>
                <?php else: ?>
                    <?php if (!empty($log['context'])): ?>
                        <?php $contextId = 'context-' . $this->getCategory() . '-' . $index; ?>
                        <?php $contextDump = $valueExporter->exportValue($log['context']); ?>

                        <div class="metadata">
                            <strong>Context</strong>:
                            <?php if (strlen($contextDump) > 120): ?>
                                <?php substr($contextDump, 120); ?> ...

                                <a class="btn-link text-small sf-toggle"
                                   data-toggle-selector="#<?php echo $contextId ?>"
                                   data-toggle-alt-content="Hide full context">Show full context</a>

                                <div id="<?php echo $contextId ?>" class="context">
                                    <pre><?php echo $contextDump ?></pre>
                                </div>
                            <?php else: ?>
                                <?php echo $contextDump ?>
                            <?php endif; ?>
                        </div>
                    <?php endif; ?>
                <?php endif; ?>


            </td>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>