Add log viewer
This commit is contained in:
parent
49b9d139ec
commit
858f71e945
24
Controller/LogViewController.php
Normal file
24
Controller/LogViewController.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ardent\LoggerBundle\Controller;
|
||||
|
||||
use App\Ardent\LoggerBundle\Service\LoggerService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class LogViewController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route(path="/view/latest/{amount}")
|
||||
*/
|
||||
public function latestLogs(LoggerService $ls, $amount = 10)
|
||||
{
|
||||
$logs = $ls->getLatest($amount);
|
||||
|
||||
dump(($logs));
|
||||
|
||||
return $this->render('@ArdentLogger/errors.html.twig', [
|
||||
'logs' => $logs,
|
||||
]);
|
||||
}
|
||||
}
|
19
Resources/views/errors.html.twig
Normal file
19
Resources/views/errors.html.twig
Normal file
@ -0,0 +1,19 @@
|
||||
{% extends '@ArdentLogger/layout.html.twig' %}
|
||||
|
||||
{% block ardent_logger_user_content %}
|
||||
Error overview <br>
|
||||
|
||||
{% for log in logs %}
|
||||
{# @var log \App\Ardent\LoggerBundle\Entity\LogEntry #}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ log.levelName }} #{{ log.id }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">{{ log.createdAt | date('D, d M y H:i:s') }}</h6>
|
||||
<p class="card-text">{{ log.message }}</p>
|
||||
{% for context in log.context %}
|
||||
<p class="card-text"> > {{ context }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
2
Resources/views/layout.html.twig
Normal file
2
Resources/views/layout.html.twig
Normal file
@ -0,0 +1,2 @@
|
||||
{% block ardent_logger_user_content %}
|
||||
{% endblock %}
|
@ -4,7 +4,6 @@ namespace App\Ardent\LoggerBundle\Service;
|
||||
|
||||
use App\Ardent\LoggerBundle\Entity\LogEntry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use phpDocumentor\Reflection\Types\This;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
|
||||
class LoggerService
|
||||
@ -168,7 +167,7 @@ class LoggerService
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function getLatest($level = self::DEBUG, $amount = 1)
|
||||
public function getLatest($amount = 1, $level = self::DEBUG)
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user