Improve looks
This commit is contained in:
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Common\Controller;
|
namespace ProVM\Common\Controller;
|
||||||
|
|
||||||
use ProVM\Common\Service\Logs;
|
use SplFileInfo;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Slim\Views\Blade as View;
|
use Slim\Views\Blade as View;
|
||||||
|
use ProVM\Common\Service\Logs;
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
{
|
{
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Logs $service): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Logs $service): ResponseInterface
|
||||||
{
|
{
|
||||||
$files = $service->getFiles();
|
$files = $service->getFiles();
|
||||||
|
usort($files, function(SplFileInfo $a, SplFileInfo $b) {
|
||||||
|
return $b->getCTime() - $a->getCTime();
|
||||||
|
});
|
||||||
return $view->render($response, 'home', compact('files'));
|
return $view->render($response, 'home', compact('files'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Common\Service;
|
namespace ProVM\Common\Service;
|
||||||
|
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use SplFileInfo;
|
||||||
use ProVM\Logview\Log\File;
|
use ProVM\Logview\Log\File;
|
||||||
|
|
||||||
class Logs
|
class Logs
|
||||||
@ -38,7 +40,9 @@ class Logs
|
|||||||
}
|
}
|
||||||
public function get(string $log_file): File
|
public function get(string $log_file): File
|
||||||
{
|
{
|
||||||
$content = \Safe\file_get_contents(implode(DIRECTORY_SEPARATOR, [$this->getFolder(), $log_file]));
|
$filename = implode(DIRECTORY_SEPARATOR, [$this->getFolder(), $log_file]);
|
||||||
return (new File())->setFilename($log_file)->setContent($content);
|
$file_info = new SplFileInfo($filename);
|
||||||
|
$content = \Safe\file_get_contents($filename);
|
||||||
|
return (new File())->setFilename($log_file)->setDate((new DateTimeImmutable())->setTimestamp($file_info->getCTime()))->setContent($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<div class="ui list">
|
<div class="ui list">
|
||||||
@foreach ($files as $file)
|
@foreach ($files as $file)
|
||||||
<a class="item" href="{{$urls->base}}/log/{{urlencode($file->getBasename())}}">{{$file->getBasename()}}</a>
|
<a class="item" href="{{$urls->base}}/log/{{urlencode($file->getBasename())}}">[{{(new DateTimeImmutable)->setTimestamp($file->getCTime())->format('Y-m-d H:i:s')}}] {{$file->getBasename()}}</a>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@extends('layout.base')
|
@extends('layout.base')
|
||||||
|
|
||||||
@section('page_title')
|
@section('page_title')
|
||||||
File {{$log->getFilename()}}
|
Log File
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -2,54 +2,58 @@
|
|||||||
|
|
||||||
@section('page_content')
|
@section('page_content')
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h3 class="ui header">Logs</h3>
|
<h3 class="ui header">Log File: {{$log->getFilename()}}</h3>
|
||||||
</div>
|
<h5 class="ui header">{{$log->getDate()->format('Y-m-d H:i:s')}}</h5>
|
||||||
<div class="ui accordion">
|
<div class="ui accordion">
|
||||||
@foreach($log->getLogs() as $line)
|
@foreach($log->getLogs() as $line)
|
||||||
<div class="title {{strtolower($line->getSeverity())}}">
|
<div class="title">
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
{{$line->getDate()->format('Y-m-d H:i:s.u')}} - {{$line->getSeverity()}}
|
<span class="{{strtolower($line->getSeverity())}}" style="padding-left: 1ex;padding-right: 1ex;">
|
||||||
</div>
|
{{$line->getDate()->format('Y-m-d H:i:s.u')}} - {{$line->getSeverity()}}
|
||||||
<div class="content">
|
</span>
|
||||||
<div class="ui fluid card">
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="header">
|
<div class="ui fluid basic card">
|
||||||
<span class="{{strtolower($line->getSeverity())}}" style="padding: 1ex 1em;">
|
<div class="content">
|
||||||
<i class="bug icon"></i>
|
<div class="header">
|
||||||
{{$line->getChannel()}}.{{$line->getSeverity()}}
|
<span class="{{strtolower($line->getSeverity())}}" style="padding: 1ex 1em;">
|
||||||
</span>
|
<i class="bug icon"></i>
|
||||||
|
{{$line->getChannel()}}.{{$line->getSeverity()}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="content">
|
||||||
<div class="content">
|
<div class="description">
|
||||||
<div class="description">
|
{{$line->getMessage()}}
|
||||||
{{$line->getMessage()}}
|
</div>
|
||||||
</div>
|
@if ($line->hasStack())
|
||||||
@if ($line->hasStack())
|
<div class="ui small feed">
|
||||||
<div class="ui small feed">
|
@foreach ($line->getStack() as $stack)
|
||||||
@foreach ($line->getStack() as $stack)
|
<div class="event">
|
||||||
<div class="event">
|
<div class="content">
|
||||||
<div class="content">
|
{{$stack}}
|
||||||
{{$stack}}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endforeach
|
||||||
@endforeach
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@if ($line->hasContext())
|
||||||
|
<div class="extra content">
|
||||||
|
{{$line->getContext()}}
|
||||||
|
<div class="meta">{{$line->getExtra()}}</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@if ($line->hasContext())
|
|
||||||
<div class="extra content">
|
|
||||||
{{$line->getContext()}}
|
|
||||||
<div class="meta">{{$line->getExtra()}}</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endforeach
|
||||||
@endforeach
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('page_styles')
|
@push('page_styles')
|
||||||
<style>
|
<style>
|
||||||
|
body {overflow-y:scroll;}
|
||||||
@foreach ($levels as $level => $colors)
|
@foreach ($levels as $level => $colors)
|
||||||
.{{$level}} {background-color: {{$colors->background}}; color: {{$colors->text}};}
|
.{{$level}} {background-color: {{$colors->background}}; color: {{$colors->text}};}
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -58,6 +62,7 @@
|
|||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$('.accordion').accordion()
|
$('.accordion').accordion()
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -16,7 +16,7 @@ class Log
|
|||||||
|
|
||||||
public function getDate(): DateTimeInterface
|
public function getDate(): DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->dateTime;
|
return $this->dateTime ?? new DateTimeImmutable();
|
||||||
}
|
}
|
||||||
public function getChannel(): string
|
public function getChannel(): string
|
||||||
{
|
{
|
||||||
@ -103,7 +103,9 @@ class Log
|
|||||||
|
|
||||||
$regex = "/\[(?P<date>.*)\]\s(?<channel>\w*)\.(?<severity>\w*):\s(?<message>.*)\s[\[|\{](?<context>.*)[\]|\}]\s\[(?<extra>.*)\]/";
|
$regex = "/\[(?P<date>.*)\]\s(?<channel>\w*)\.(?<severity>\w*):\s(?<message>.*)\s[\[|\{](?<context>.*)[\]|\}]\s\[(?<extra>.*)\]/";
|
||||||
preg_match($regex, $content, $matches);
|
preg_match($regex, $content, $matches);
|
||||||
$log->setDate(DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', $matches['date']));
|
if (isset($matches['date'])) {
|
||||||
|
$log->setDate(DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', $matches['date']));
|
||||||
|
}
|
||||||
$log->setChannel($matches['channel']);
|
$log->setChannel($matches['channel']);
|
||||||
$log->setSeverity($matches['severity']);
|
$log->setSeverity($matches['severity']);
|
||||||
$message = $matches['message'];
|
$message = $matches['message'];
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Logview\Log;
|
namespace ProVM\Logview\Log;
|
||||||
|
|
||||||
use Generator;
|
use DateTimeInterface;
|
||||||
use ProVM\Logview\Log;
|
use ProVM\Logview\Log;
|
||||||
|
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
protected string $filename;
|
protected string $filename;
|
||||||
|
protected DateTimeInterface $dateTime;
|
||||||
protected string $content;
|
protected string $content;
|
||||||
|
|
||||||
public function getFilename(): string
|
public function getFilename(): string
|
||||||
{
|
{
|
||||||
return $this->filename;
|
return $this->filename;
|
||||||
}
|
}
|
||||||
|
public function getDate(): DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->dateTime;
|
||||||
|
}
|
||||||
public function getContent(): string
|
public function getContent(): string
|
||||||
{
|
{
|
||||||
return $this->content;
|
return $this->content;
|
||||||
@ -23,6 +28,11 @@ class File
|
|||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function setDate(DateTimeInterface $dateTime): File
|
||||||
|
{
|
||||||
|
$this->dateTime = $dateTime;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
public function setContent(string $content): File
|
public function setContent(string $content): File
|
||||||
{
|
{
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
|
Reference in New Issue
Block a user