Skip to content

Commit 436d997

Browse files
committed
small refactor + version bump
1 parent 4f49a0b commit 436d997

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ Gate::define('deleteLogFolder', function (?User $user, LogFolder $folder) {
279279

280280
**NOTE:** Individual file permissions are also checked before deleting them, to avoid accidental deletion of protected log files.
281281

282+
### Disabling Log Viewer
283+
284+
To disable web access to the Log Viewer, just add an environment variable to your `.env` file:
285+
286+
```env
287+
LOG_VIEWER_ENABLED=false
288+
```
289+
282290
## Troubleshooting
283291

284292
Here are some common problems and solutions.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opcodesio/log-viewer",
3-
"version": "v1.7.0",
3+
"version": "v1.7.1",
44
"description": "Fast and easy-to-use log viewer for your Laravel application",
55
"keywords": [
66
"arukompas",

config/log-viewer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
return [
66

7+
/*
8+
|--------------------------------------------------------------------------
9+
| Log Viewer
10+
|--------------------------------------------------------------------------
11+
| Log Viewer can be disabled, so it's no longer accessible via browser.
12+
|
13+
*/
14+
'enabled' => env('LOG_VIEWER_ENABLED', true),
15+
716
/*
817
|--------------------------------------------------------------------------
918
| Log Viewer Domain
@@ -25,13 +34,6 @@
2534

2635
'route_path' => 'log-viewer',
2736

28-
/*
29-
|--------------------------------------------------------------------------
30-
| Log Viewer Activation
31-
|--------------------------------------------------------------------------
32-
*/
33-
'enabled' => true,
34-
3537
/*
3638
|--------------------------------------------------------------------------
3739
| Back to system URL

src/LogViewerServiceProvider.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ public function register()
2424
$this->app->singleton(PreferenceStore::class, PreferenceStore::class);
2525
}
2626

27-
private function basePath(string $path): string
28-
{
29-
return __DIR__ . '/..' . $path;
30-
}
31-
32-
/**
33-
* Check if config is enabled
34-
*
35-
* @return bool
36-
*/
37-
public function isEnabled(): bool
38-
{
39-
return (bool) $this->app['config']->get("{$this->name}.enabled", true);
40-
}
41-
4227
public function boot()
4328
{
4429
if ($this->app->runningInConsole()) {
@@ -51,7 +36,7 @@ public function boot()
5136
$this->commands([GenerateDummyLogsCommand::class]);
5237
}
5338

54-
if (!$this->isEnabled()) {
39+
if (! $this->isEnabled()) {
5540
return;
5641
}
5742

@@ -68,20 +53,30 @@ public function boot()
6853
LogViewer::clearFileCache();
6954
});
7055

71-
if (!Gate::has('downloadLogFile')) {
56+
if (! Gate::has('downloadLogFile')) {
7257
Gate::define('downloadLogFile', fn (mixed $user, LogFile $file) => true);
7358
}
7459

75-
if (!Gate::has('downloadLogFolder')) {
60+
if (! Gate::has('downloadLogFolder')) {
7661
Gate::define('downloadLogFolder', fn (mixed $user, LogFolder $folder) => true);
7762
}
7863

79-
if (!Gate::has('deleteLogFile')) {
64+
if (! Gate::has('deleteLogFile')) {
8065
Gate::define('deleteLogFile', fn (mixed $user, LogFile $file) => true);
8166
}
8267

83-
if (!Gate::has('deleteLogFolder')) {
68+
if (! Gate::has('deleteLogFolder')) {
8469
Gate::define('deleteLogFolder', fn (mixed $user, LogFolder $folder) => true);
8570
}
8671
}
72+
73+
private function basePath(string $path): string
74+
{
75+
return __DIR__ . '/..' . $path;
76+
}
77+
78+
private function isEnabled(): bool
79+
{
80+
return (bool) $this->app['config']->get("{$this->name}.enabled", true);
81+
}
8782
}

0 commit comments

Comments
 (0)