feat: replace log viewer

This commit is contained in:
Miguel Nogueira 2022-09-04 19:49:10 +01:00
parent afa5970080
commit 8a3b4c432a
No known key found for this signature in database
GPG Key ID: 3C6A7E29AF26D370
7 changed files with 243 additions and 298 deletions

View File

@ -47,6 +47,7 @@ use App\Vote;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
@ -90,5 +91,17 @@ class AuthServiceProvider extends ServiceProvider
->salutation('The team at ' . config('app.name'));
});
Gate::define('viewLogViewer', function (?User $user){
return $user->hasPermissionTo('admin.developertools.use');
});
Gate::define('downloadLogFile', function (User $user){
return $user->hasPermissionTo('admin.developertools.use');
});
Gate::define('deleteLogFile', function (User $user){
return $user->hasPermissionTo('admin.developertools.use');
});
}
}

View File

@ -10,7 +10,6 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"arcanedev/log-viewer": "^9.0.0",
"doctrine/dbal": "^2.10",
"fruitcake/laravel-cors": "^2.1",
"geo-sot/laravel-env-editor": "^1.1.0",
@ -26,6 +25,7 @@
"laravel/ui": "^3.0",
"mcamara/laravel-localization": "^1.7",
"mpociot/teamwork": "^7.0",
"opcodesio/log-viewer": "^1.2",
"pragmarx/google2fa-laravel": "^1.3",
"sentry/sentry-laravel": "2.11.*",
"socialiteproviders/discord": "^4.1",

291
composer.lock generated
View File

@ -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": "2b00362eaed0b6018ba0415a503c5079",
"content-hash": "504cb41919ce3a39fda05c168bf1193c",
"packages": [
{
"name": "almasaeed2010/adminlte",
@ -49,144 +49,6 @@
},
"time": "2022-02-07T20:33:09+00:00"
},
{
"name": "arcanedev/log-viewer",
"version": "9.0.0",
"source": {
"type": "git",
"url": "https://github.com/ARCANEDEV/LogViewer.git",
"reference": "ba0c14ef65c93fae6745ff0607a14d83d39e3faa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ARCANEDEV/LogViewer/zipball/ba0c14ef65c93fae6745ff0607a14d83d39e3faa",
"reference": "ba0c14ef65c93fae6745ff0607a14d83d39e3faa",
"shasum": ""
},
"require": {
"arcanedev/support": "^9.0",
"ext-json": "*",
"php": "^8.0",
"psr/log": "^1.0|^2.0|^3.0"
},
"require-dev": {
"laravel/framework": "^9.0",
"mockery/mockery": "^1.4.4",
"orchestra/testbench-core": "^7.0",
"phpunit/phpunit": "^9.5.10"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "10.x-dev"
},
"laravel": {
"providers": [
"Arcanedev\\LogViewer\\LogViewerServiceProvider",
"Arcanedev\\LogViewer\\Providers\\DeferredServicesProvider"
]
}
},
"autoload": {
"files": [
"helpers.php"
],
"psr-4": {
"Arcanedev\\LogViewer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "ARCANEDEV",
"email": "arcanedev.maroc@gmail.com",
"homepage": "https://github.com/arcanedev-maroc",
"role": "Developer"
}
],
"description": "Provides a Log Viewer for Laravel",
"homepage": "https://github.com/ARCANEDEV/LogViewer",
"keywords": [
"arcanedev",
"arcanesoft",
"laravel",
"log",
"log viewer",
"log-viewer",
"logviewer"
],
"support": {
"issues": "https://github.com/ARCANEDEV/LogViewer/issues",
"source": "https://github.com/ARCANEDEV/LogViewer/tree/9.0.0"
},
"time": "2022-02-10T21:20:19+00:00"
},
{
"name": "arcanedev/support",
"version": "9.0.0",
"source": {
"type": "git",
"url": "https://github.com/ARCANEDEV/Support.git",
"reference": "046d87b2d638cd0687b4ba06991947df2422970d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ARCANEDEV/Support/zipball/046d87b2d638cd0687b4ba06991947df2422970d",
"reference": "046d87b2d638cd0687b4ba06991947df2422970d",
"shasum": ""
},
"require": {
"illuminate/contracts": "^9.0",
"illuminate/support": "^9.0",
"php": "^8.0.2"
},
"require-dev": {
"laravel/framework": "^9.0",
"orchestra/testbench-core": "^7.0",
"phpunit/phpunit": "^9.5.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "10.x-dev"
}
},
"autoload": {
"files": [
"helpers.php"
],
"psr-4": {
"Arcanedev\\Support\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "ARCANEDEV",
"email": "arcanedev.maroc@gmail.com",
"homepage": "https://github.com/arcanedev-maroc"
}
],
"description": "ARCANEDEV Support Helpers",
"homepage": "https://github.com/ARCANEDEV/Support",
"keywords": [
"arcanedev",
"arcanesoft",
"laravel",
"support"
],
"support": {
"issues": "https://github.com/ARCANEDEV/Support/issues",
"source": "https://github.com/ARCANEDEV/Support/tree/9.0.0"
},
"time": "2022-02-10T19:52:50+00:00"
},
{
"name": "bacon/bacon-qr-code",
"version": "2.0.6",
@ -3091,6 +2953,79 @@
},
"time": "2021-08-15T23:05:49+00:00"
},
{
"name": "livewire/livewire",
"version": "v2.10.7",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "fa0441bf82f1674beecb3a8ad8a4ae428736ed18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/fa0441bf82f1674beecb3a8ad8a4ae428736ed18",
"reference": "fa0441bf82f1674beecb3a8ad8a4ae428736ed18",
"shasum": ""
},
"require": {
"illuminate/database": "^7.0|^8.0|^9.0",
"illuminate/support": "^7.0|^8.0|^9.0",
"illuminate/validation": "^7.0|^8.0|^9.0",
"league/mime-type-detection": "^1.9",
"php": "^7.2.5|^8.0",
"symfony/http-kernel": "^5.0|^6.0"
},
"require-dev": {
"calebporzio/sushi": "^2.1",
"laravel/framework": "^7.0|^8.0|^9.0",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "^5.0|^6.0|^7.0",
"orchestra/testbench-dusk": "^5.2|^6.0|^7.0",
"phpunit/phpunit": "^8.4|^9.0",
"psy/psysh": "@stable"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Livewire\\LivewireServiceProvider"
],
"aliases": {
"Livewire": "Livewire\\Livewire"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Livewire\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Caleb Porzio",
"email": "calebporzio@gmail.com"
}
],
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v2.10.7"
},
"funding": [
{
"url": "https://github.com/livewire",
"type": "github"
}
],
"time": "2022-08-08T13:52:53+00:00"
},
{
"name": "mcamara/laravel-localization",
"version": "v1.7.0",
@ -3708,6 +3643,84 @@
],
"time": "2022-02-02T18:37:57+00:00"
},
{
"name": "opcodesio/log-viewer",
"version": "v1.2.9",
"source": {
"type": "git",
"url": "https://github.com/opcodesio/log-viewer.git",
"reference": "c360b9682b2963f99b8cbe08f0cda37dff41f5cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opcodesio/log-viewer/zipball/c360b9682b2963f99b8cbe08f0cda37dff41f5cb",
"reference": "c360b9682b2963f99b8cbe08f0cda37dff41f5cb",
"shasum": ""
},
"require": {
"illuminate/contracts": "^8.0|^9.0",
"livewire/livewire": "^2.10",
"php": "^8.0"
},
"conflict": {
"arcanedev/log-viewer": "^8.0"
},
"require-dev": {
"itsgoingd/clockwork": "^5.1",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0",
"orchestra/testbench": "^7.6",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpunit/phpunit": "^9.5",
"spatie/test-time": "^1.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Opcodes\\LogViewer\\LogViewerServiceProvider"
],
"aliases": {
"LogViewer": "Opcodes\\LogViewer\\Facades\\LogViewer"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Opcodes\\LogViewer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Arunas Skirius",
"email": "arukomp@gmail.com",
"role": "Developer"
}
],
"description": "Fast and easy-to-use log viewer for your Laravel application",
"homepage": "https://github.com/opcodesio/log-viewer",
"keywords": [
"arukompas",
"better-log-viewer",
"laravel",
"log viewer",
"logs",
"opcodesio"
],
"support": {
"issues": "https://github.com/opcodesio/log-viewer/issues",
"source": "https://github.com/opcodesio/log-viewer/tree/v1.2.9"
},
"time": "2022-09-04T13:32:18+00:00"
},
{
"name": "paragonie/constant_time_encoding",
"version": "v2.5.0",

View File

@ -380,16 +380,16 @@ return [
[
'text' => 'm_devtools',
'icon' => 'fas fa-code',
'url' => '/admin/devtools',
'route' => 'devTools',
'can' => 'admin.developertools.use',
],
],
],
[
'text' => 'm_s_logs',
'url' => '/admin/maintenance/system-logs',
'text' => 'App logs',
'url' => '/admin/developers/logs',
'icon' => 'fas fa-clipboard-list',
'can' => 'admin.maintenance.logs.view',
'can' => 'admin.developertools.use',
],
],

206
config/log-viewer.php Executable file → Normal file
View File

@ -1,160 +1,76 @@
<?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
use Arcanedev\LogViewer\Contracts\Utilities\Filesystem;
return [
/* -----------------------------------------------------------------
| Log files storage path
| -----------------------------------------------------------------
/*
|--------------------------------------------------------------------------
| Log Viewer Route
|--------------------------------------------------------------------------
| Log Viewer will be available under this URL.
|
*/
'storage-path' => storage_path('logs'),
'route_path' => 'admin/developers/logs',
/* -----------------------------------------------------------------
| Log files pattern
| -----------------------------------------------------------------
/*
|--------------------------------------------------------------------------
| Back to system URL
|--------------------------------------------------------------------------
| When set, displays a link to easily get back to this URL.
| Set to `null` to hide this link.
|
| Optional label to display for the above URL.
|
*/
'pattern' => [
'prefix' => Filesystem::PATTERN_PREFIX, // 'laravel-'
'date' => Filesystem::PATTERN_DATE, // '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
'extension' => Filesystem::PATTERN_EXTENSION, // '.log'
'back_to_system_url' => '/admin/developers',
'back_to_system_label' => 'Back to Developer Tools', // Displayed by default: "Back to {{ app.name }}"
/*
|--------------------------------------------------------------------------
| Log Viewer route middleware.
|--------------------------------------------------------------------------
| The middleware should enable session and cookies support in order for the Log Viewer to work.
| The 'web' middleware will be applied automatically if empty.
|
*/
'middleware' => ['web', 'auth'],
/*
|--------------------------------------------------------------------------
| Include file patterns
|--------------------------------------------------------------------------
|
*/
'include_files' => ['*.log'],
/*
|--------------------------------------------------------------------------
| Exclude file patterns.
|--------------------------------------------------------------------------
| This will take precedence over included files.
|
*/
'exclude_files' => [
//'my_secret.log'
],
/* -----------------------------------------------------------------
| Locale
| -----------------------------------------------------------------
| Supported locales :
| 'auto', 'ar', 'bg', 'de', 'en', 'es', 'et', 'fa', 'fr', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'nl',
| 'pl', 'pt-BR', 'ro', 'ru', 'sv', 'th', 'tr', 'zh-TW', 'zh'
/*
|--------------------------------------------------------------------------
| Shorter stack trace filters.
|--------------------------------------------------------------------------
| Lines containing any of these strings will be excluded from the full log.
| This setting is only active when the function is enabled via the user interface.
|
*/
'locale' => 'auto',
/* -----------------------------------------------------------------
| Theme
| -----------------------------------------------------------------
| Supported themes :
| 'bootstrap-3', 'bootstrap-4'
| Make your own theme by adding a folder to the views directory and specifying it here.
*/
'theme' => 'bootstrap-4',
/* -----------------------------------------------------------------
| Route settings
| -----------------------------------------------------------------
*/
'route' => [
'enabled' => true,
'attributes' => [
'prefix' => 'admin/maintenance/system-logs',
'middleware' => env('ARCANEDEV_LOGVIEWER_MIDDLEWARE') ? explode(',', env('ARCANEDEV_LOGVIEWER_MIDDLEWARE')) : null,
'shorter_stack_trace_excludes' => [
'/vendor/symfony/',
'/vendor/laravel/framework/',
'/vendor/barryvdh/laravel-debugbar/',
],
],
/* -----------------------------------------------------------------
| Log entries per page
| -----------------------------------------------------------------
| This defines how many logs & entries are displayed per page.
*/
'per-page' => 30,
/* -----------------------------------------------------------------
| Download settings
| -----------------------------------------------------------------
*/
'download' => [
'prefix' => 'rpnetlog-',
'extension' => 'log',
],
/* -----------------------------------------------------------------
| Menu settings
| -----------------------------------------------------------------
*/
'menu' => [
'filter-route' => 'log-viewer::logs.filter',
'icons-enabled' => true,
],
/* -----------------------------------------------------------------
| Icons
| -----------------------------------------------------------------
*/
'icons' => [
/**
* Font awesome >= 4.3
* http://fontawesome.io/icons/.
*/
'all' => 'fa fa-fw fa-list', // http://fontawesome.io/icon/list/
'emergency' => 'fa fa-fw fa-bug', // http://fontawesome.io/icon/bug/
'alert' => 'fa fa-fw fa-bullhorn', // http://fontawesome.io/icon/bullhorn/
'critical' => 'fa fa-fw fa-heartbeat', // http://fontawesome.io/icon/heartbeat/
'error' => 'fa fa-fw fa-times-circle', // http://fontawesome.io/icon/times-circle/
'warning' => 'fa fa-fw fa-exclamation-triangle', // http://fontawesome.io/icon/exclamation-triangle/
'notice' => 'fa fa-fw fa-exclamation-circle', // http://fontawesome.io/icon/exclamation-circle/
'info' => 'fa fa-fw fa-info-circle', // http://fontawesome.io/icon/info-circle/
'debug' => 'fa fa-fw fa-life-ring', // http://fontawesome.io/icon/life-ring/
],
/* -----------------------------------------------------------------
| Colors
| -----------------------------------------------------------------
*/
'colors' => [
'levels' => [
'empty' => '#D1D1D1',
'all' => '#8A8A8A',
'emergency' => '#B71C1C',
'alert' => '#D32F2F',
'critical' => '#F44336',
'error' => '#FF5722',
'warning' => '#FF9100',
'notice' => '#4CAF50',
'info' => '#1976D2',
'debug' => '#90CAF9',
],
],
/* -----------------------------------------------------------------
| Strings to highlight in stack trace
| -----------------------------------------------------------------
*/
'highlight' => [
'^#\d+',
'^Stack trace:',
],
];

View File

@ -299,6 +299,9 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
Route::delete('accounts/delete/{user}', [UserController::class, 'delete'])
->name('deleteUser');
Route::patch('accounts/force-reset/{user}', [UserController::class, 'forcePasswordReset'])
->name('force-reset-user');
Route::patch('accounts/update/{user}', [UserController::class, 'update'])
->name('updateUser');
@ -345,7 +348,7 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
->name('updateForm');
Route::group(['prefix' => 'devtools'], function () {
Route::group(['prefix' => 'developers'], function () {
Route::get('/', [DevToolsController::class, 'index'])
->name('devTools');