From 858f71e945e5f2094d995f4dba2b96f2b25f29be Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 29 May 2019 17:44:49 +0200 Subject: [PATCH] Add log viewer --- Controller/LogViewController.php | 24 ++++++++++++++++++++++++ Resources/views/errors.html.twig | 19 +++++++++++++++++++ Resources/views/layout.html.twig | 2 ++ Service/LoggerService.php | 3 +-- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Controller/LogViewController.php create mode 100644 Resources/views/errors.html.twig create mode 100644 Resources/views/layout.html.twig diff --git a/Controller/LogViewController.php b/Controller/LogViewController.php new file mode 100644 index 0000000..327c2ff --- /dev/null +++ b/Controller/LogViewController.php @@ -0,0 +1,24 @@ +getLatest($amount); + + dump(($logs)); + + return $this->render('@ArdentLogger/errors.html.twig', [ + 'logs' => $logs, + ]); + } +} diff --git a/Resources/views/errors.html.twig b/Resources/views/errors.html.twig new file mode 100644 index 0000000..07b4891 --- /dev/null +++ b/Resources/views/errors.html.twig @@ -0,0 +1,19 @@ +{% extends '@ArdentLogger/layout.html.twig' %} + +{% block ardent_logger_user_content %} + Error overview
+ + {% for log in logs %} + {# @var log \App\Ardent\LoggerBundle\Entity\LogEntry #} +
+
+
{{ log.levelName }} #{{ log.id }}
+
{{ log.createdAt | date('D, d M y H:i:s') }}
+

{{ log.message }}

+ {% for context in log.context %} +

> {{ context }}

+ {% endfor %} +
+
+ {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig new file mode 100644 index 0000000..1549a3a --- /dev/null +++ b/Resources/views/layout.html.twig @@ -0,0 +1,2 @@ +{% block ardent_logger_user_content %} +{% endblock %} \ No newline at end of file diff --git a/Service/LoggerService.php b/Service/LoggerService.php index 640ddcf..e85aae9 100644 --- a/Service/LoggerService.php +++ b/Service/LoggerService.php @@ -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();