From b9c143bab55006d42dcd27484fe9ace9a6a0173c Mon Sep 17 00:00:00 2001 From: aslan Date: Mon, 11 Mar 2024 14:31:45 +0300 Subject: [PATCH] add Logging to project with route admin/logs --- composer.json | 1 + composer.lock | 65 +++- config/logging.php | 8 + .../vendor/laravel-log-viewer/log.blade.php | 334 ++++++++++++++++++ routes/admin.php | 3 + 5 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 resources/views/vendor/laravel-log-viewer/log.blade.php diff --git a/composer.json b/composer.json index 05994c9..25c6d9c 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "laravel/ui": "^4.5.0", "laravelcollective/html": "^6.4.1", "league/flysystem": "^3.25.0", + "rap2hpoutre/laravel-log-viewer": "^2.3", "twbs/bootstrap": "5.2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index f9c5c10..39ba8fe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a8ef8e1a8cc4569e75864f1e869dcb34", + "content-hash": "b08e2f37cdd3c92cbf32d616488c1231", "packages": [ { "name": "brick/math", @@ -3435,6 +3435,69 @@ ], "time": "2023-11-08T05:53:05+00:00" }, + { + "name": "rap2hpoutre/laravel-log-viewer", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/rap2hpoutre/laravel-log-viewer.git", + "reference": "c4148ec364d78be13eb2ab81ce860946bfd91c4c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rap2hpoutre/laravel-log-viewer/zipball/c4148ec364d78be13eb2ab81ce860946bfd91c4c", + "reference": "c4148ec364d78be13eb2ab81ce860946bfd91c4c", + "shasum": "" + }, + "require": { + "illuminate/support": "4.2.*|5.*|^6.0|^7.0|^8.0|^9.0|^10.0", + "php": ">=5.4.0" + }, + "require-dev": { + "orchestra/testbench": "3.7.*|^7.0", + "phpunit/phpunit": "^7|^9.5.10" + }, + "type": "laravel-package", + "extra": { + "laravel": { + "providers": [ + "Rap2hpoutre\\LaravelLogViewer\\LaravelLogViewerServiceProvider" + ] + } + }, + "autoload": { + "psr-0": { + "Rap2hpoutre\\LaravelLogViewer\\": "src/" + }, + "classmap": [ + "src/controllers" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "rap2hpoutre", + "email": "raphaelht@gmail.com" + } + ], + "description": "A Laravel log reader", + "keywords": [ + "laravel", + "log", + "log-reader", + "log-viewer", + "logging", + "lumen" + ], + "support": { + "issues": "https://github.com/rap2hpoutre/laravel-log-viewer/issues", + "source": "https://github.com/rap2hpoutre/laravel-log-viewer/tree/v2.3.0" + }, + "time": "2023-02-15T07:36:34+00:00" + }, { "name": "symfony/console", "version": "v6.4.4", diff --git a/config/logging.php b/config/logging.php index c44d276..9b92ee8 100644 --- a/config/logging.php +++ b/config/logging.php @@ -58,6 +58,14 @@ return [ 'ignore_exceptions' => false, ], + 'app' => [ + 'driver' => 'single', + 'path' => storage_path('logs/app.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, + ], + + 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), diff --git a/resources/views/vendor/laravel-log-viewer/log.blade.php b/resources/views/vendor/laravel-log-viewer/log.blade.php new file mode 100644 index 0000000..47245c0 --- /dev/null +++ b/resources/views/vendor/laravel-log-viewer/log.blade.php @@ -0,0 +1,334 @@ + + + + + + + Laravel log viewer + + + + + + + +
+
+ +
+ @if ($logs === null) +
+ Log file >50M, please download it. +
+ @else + + + + @if ($standardFormat) + + + + @else + + @endif + + + + + + @foreach($logs as $key => $log) + + @if ($standardFormat) + + + @endif + + + + @endforeach + + +
LevelContextDateLine numberContent
+   {{$log['level']}} + {{$log['context']}}{{{$log['date']}}} + @if ($log['stack']) + + @endif + {{{$log['text']}}} + @if (isset($log['in_file'])) +
{{{$log['in_file']}}} + @endif + @if ($log['stack']) + + @endif +
+ @endif +{{--
--}} +{{-- @if($current_file)--}} +{{-- --}} +{{-- Download file--}} +{{-- --}} +{{-- ---}} +{{-- --}} +{{-- Clean file--}} +{{-- --}} +{{-- ---}} +{{-- --}} +{{-- Delete file--}} +{{-- --}} +{{-- @if(count($files) > 1)--}} +{{-- ---}} +{{-- --}} +{{-- Delete all files--}} +{{-- --}} +{{-- @endif--}} +{{-- @endif--}} +{{--
--}} +
+
+
+ + + + + + + + + + + + diff --git a/routes/admin.php b/routes/admin.php index 9d9c9ec..4c3fae4 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -14,8 +14,11 @@ use App\Http\Controllers\admin\Catalog\EducationalInstitutionController; use App\Http\Controllers\admin\Catalog\FacultyController; use App\Http\Controllers\admin\DocumentController; use App\Http\Controllers\admin\UserController; +use Rap2hpoutre\LaravelLogViewer\LogViewerController; Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { + Route::get('/logs', [LogViewerController::class, 'index']); + Route::get('/dashboard', function () { return view('admin'); })->name('dashboard');