<?php
$this->layout('main', ['title' => $title, 'manual' => true]);
?>

<?php foreach ($log_records as $id => $row): ?>
    <div class="card mb-3" id="log-view">
        <div class="card-header" id="log-row-<?=$id?>">
            <h4 class="mb-0">
                <?php if ($row['level'] === \Monolog\Logger::DEBUG): ?>
                    <span class="badge badge-info">Debug</span>
                <?php elseif ($row['level'] === \Monolog\Logger::INFO): ?>
                    <span class="badge badge-info">Info</span>
                <?php elseif ($row['level'] === \Monolog\Logger::NOTICE): ?>
                    <span class="badge badge-info">Notice</span>
                <?php elseif ($row['level'] === \Monolog\Logger::WARNING): ?>
                    <span class="badge badge-warning">Warning</span>
                <?php elseif ($row['level'] === \Monolog\Logger::ERROR): ?>
                    <span class="badge badge-danger">Error</span>
                <?php elseif ($row['level'] === \Monolog\Logger::CRITICAL): ?>
                    <span class="badge badge-danger">Critical</span>
                <?php elseif ($row['level'] === \Monolog\Logger::ALERT): ?>
                    <span class="badge badge-danger">Alert</span>
                <?php elseif ($row['level'] === \Monolog\Logger::EMERGENCY): ?>
                    <span class="badge badge-danger">Emergency</span>
                <?php endif; ?>

                <?=$this->e($row['message'])?>
            </h4>

            <?php if (!empty($row['context']) || !empty($row['extra'])): ?>
                <div class="buttons mt-3">
                    <button class="btn btn-sm btn-bg" type="button" data-toggle="collapse" data-target="#detail-row-<?=$id?>" aria-controls="detail-row-<?=$id?>">
                        <?=__('Details')?>
                    </button>
                </div>
            <?php endif; ?>
        </div>

        <?php if (!empty($row['context']) || !empty($row['extra'])): ?>
            <div id="detail-row-<?=$id?>" class="collapse" aria-labelledby="log-row-<?=$id?>" data-parent="#log-view">
                <div class="card-body pb-0">
                    <dl>
                        <?php foreach ($row['context'] as $context_header => $context_value): ?>
                            <dt><?=$context_header?></dt>
                            <dd><?=$this->dump($context_value)?></dd>
                        <?php endforeach; ?>
                        <?php foreach ($row['extra'] as $context_header => $context_value): ?>
                            <dt><?=$context_header?></dt>
                            <dd><?=$this->dump($context_value)?></dd>
                        <?php endforeach; ?>
                    </dl>
                </div>
            </div>
        <?php endif; ?>
    </div>
<?php endforeach; ?>
