Skip to content

Commit

Permalink
Added log viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
yungifez committed Dec 1, 2022
1 parent feb2546 commit f7d9106
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"laravel/tinker": "^2.7",
"livewire/livewire": "^2.5",
"nnjeim/world": "^1.1",
"opcodesio/log-viewer": "^1.7",
"spatie/laravel-model-status": "^1.11",
"spatie/laravel-permission": "^5.5"
},
Expand Down
77 changes: 76 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions config/adminlte.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,14 @@
],
],
],
[
'type' => 'sidebar-menu-item',
'text' => 'View Logs',
'url' => "/logs",
'icon' => 'fa fa-sticky-note',
//it checks with roles for now so this is to prevent other users from viewing menu item
'can' => 'view logs',
],
],

/*
Expand Down
139 changes: 139 additions & 0 deletions config/log-viewer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php

use Opcodes\LogViewer\Level;

return [

/*
|--------------------------------------------------------------------------
| Log Viewer
|--------------------------------------------------------------------------
| Log Viewer can be disabled, so it's no longer accessible via browser.
|
*/
'enabled' => env('LOG_VIEWER_ENABLED', true),

/*
|--------------------------------------------------------------------------
| Log Viewer Domain
|--------------------------------------------------------------------------
| You may change the domain where Log Viewer should be active.
| If the domain is empty, all domains will be valid.
|
*/

'route_domain' => null,

/*
|--------------------------------------------------------------------------
| Log Viewer Route
|--------------------------------------------------------------------------
| Log Viewer will be available under this URL.
|
*/

'route_path' => 'logs',

/*
|--------------------------------------------------------------------------
| 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.
|
*/

'back_to_system_url' => config('app.url', null),

'back_to_system_label' => "Back to dashboard", // 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', 'role:super-admin'],

/*
|--------------------------------------------------------------------------
| Include file patterns
|--------------------------------------------------------------------------
|
*/

'include_files' => [
'*.log',
],

/*
|--------------------------------------------------------------------------
| Exclude file patterns.
|--------------------------------------------------------------------------
| This will take precedence over included files.
|
*/

'exclude_files' => [
//'my_secret.log'
],

/*
|--------------------------------------------------------------------------
| 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.
|
*/

'shorter_stack_trace_excludes' => [
'/vendor/symfony/',
'/vendor/laravel/framework/',
'/vendor/barryvdh/laravel-debugbar/',
],

/*
|--------------------------------------------------------------------------
| Log matching patterns
|--------------------------------------------------------------------------
| Regexes for matching log files
|
*/

'patterns' => [
'laravel' => [
'log_matching_regex' => '/^\[(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}\.?(\d{6}([\+-]\d\d:\d\d)?)?)\].*/',

/**
* This pattern, used for processing Laravel logs, returns these results:
* $matches[0] - the full log line being tested.
* $matches[1] - full timestamp between the square brackets (includes microseconds and timezone offset)
* $matches[2] - timestamp microseconds, if available
* $matches[3] - timestamp timezone offset, if available
* $matches[4] - contents between timestamp and the severity level
* $matches[5] - environment (local, production, etc)
* $matches[6] - log severity (info, debug, error, etc)
* $matches[7] - the log text, the rest of the text.
*/
'log_parsing_regex' => '/^\[(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}\.?(\d{6}([\+-]\d\d:\d\d)?)?)\](.*?(\w+)\.|.*?)('
.implode('|', array_filter(Level::caseValues()))
.')?: (.*?)( in [\/].*?:[0-9]+)?$/is',
],
],

/*
|--------------------------------------------------------------------------
| Chunk size when scanning log files lazily
|--------------------------------------------------------------------------
| The size in MB of files to scan before updating the progress bar when searching across all files.
|
*/

'lazy_scan_chunk_size_in_mb' => 200,
];
Empty file modified storage/fonts/DejaVuSans-Bold.ufm.json
100644 → 100755
Empty file.
Empty file modified storage/fonts/Helvetica.afm.json
100644 → 100755
Empty file.

0 comments on commit f7d9106

Please sign in to comment.