Skip to content

Commit 931e093

Browse files
committed
update README.md to include the official website link
1 parent 436d997 commit 931e093

File tree

1 file changed

+5
-222
lines changed

1 file changed

+5
-222
lines changed

README.md

Lines changed: 5 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
<p align="center">
88
<a href="#features">Features</a> |
99
<a href="#installation">Installation</a> |
10-
<a href="#configuration">Configuration</a> |
11-
<a href="#authorization">Authorization</a> |
10+
<a href="https://log-viewer.opcodes.io/">Documentation</a> |
1211
<a href="#troubleshooting">Troubleshooting</a> |
1312
<a href="#credits">Credits</a>
1413
</p>
@@ -31,6 +30,8 @@ Log Viewer helps you quickly and clearly see individual log entries, to **search
3130

3231
> 📺 **[Watch a quick 4-minute video](https://www.youtube.com/watch?v=q7SnF2vubRE)** showcasing some Log Viewer features.
3332
33+
> Visit the [official website](https://log-viewer.opcodes.io/).
34+
3435
### Features
3536

3637
- 📂 **View all the Laravel logs** in your `storage/logs` directory,
@@ -39,7 +40,7 @@ Log Viewer helps you quickly and clearly see individual log entries, to **search
3940
- 🔗 **Sharable links** to individual log entries,
4041
- 🌑 **Dark mode**
4142
- 💾 **Download & delete** log files from the UI,
42-
- ☑️ **Horizon** log support,
43+
- ☑️ **Horizon** log support (up to Horizon v9.20)
4344
- and more...
4445

4546
## Get Started
@@ -67,225 +68,7 @@ By default, the application is available at: `{APP_URL}/log-viewer`.
6768

6869
## Configuration
6970

70-
### Config file
71-
72-
To publish the [config file](https://github.com/opcodesio/log-viewer/blob/main/config/log-viewer.php), run:
73-
74-
```bash
75-
php artisan vendor:publish --tag="log-viewer-config"
76-
```
77-
78-
### Route & Middleware
79-
80-
You can easily change the default route and its middleware in the config/log-viewer.php.
81-
82-
See the configuration below:
83-
84-
```php
85-
/*
86-
|--------------------------------------------------------------------------
87-
| Log Viewer Domain
88-
|--------------------------------------------------------------------------
89-
| You may change the domain where Log Viewer should be active.
90-
| If the domain is empty, all domains will be valid.
91-
|
92-
*/
93-
94-
'route_domain' => null,
95-
96-
/*
97-
|--------------------------------------------------------------------------
98-
| Log Viewer Route
99-
|--------------------------------------------------------------------------
100-
| Log Viewer will be available under this URL.
101-
|
102-
*/
103-
104-
'route_path' => 'log-viewer',
105-
106-
/*
107-
|--------------------------------------------------------------------------
108-
| Log Viewer route middleware.
109-
|--------------------------------------------------------------------------
110-
| The middleware should enable session and cookies support in order for the Log Viewer to work.
111-
| The 'web' middleware will be applied automatically if empty.
112-
|
113-
*/
114-
115-
'middleware' => ['web'],
116-
```
117-
118-
## Authorization
119-
120-
Several things can be configured to have different access based on the user logged in, or the log file in action.
121-
122-
Here are the permissions and how to set them up.
123-
124-
### Authorizing Log Viewer access
125-
126-
You can limit who has access to the Log Viewer in several ways.
127-
128-
#### Via "auth" callback
129-
You can limit access to the Log Viewer by providing a custom authorization callback to the `LogViewer::auth()` method within your `AppServiceProvider`, like so:
130-
131-
```php
132-
use Opcodes\LogViewer\Facades\LogViewer;
133-
134-
/**
135-
* Bootstrap any application services.
136-
*
137-
* @return void
138-
*/
139-
public function boot()
140-
{
141-
LogViewer::auth(function ($request) {
142-
// return true to allow viewing the Log Viewer.
143-
});
144-
145-
// Here's an example:
146-
LogViewer::auth(function ($request) {
147-
return $request->user()
148-
&& in_array($request->user()->email, [
149-
// 'john@example.com',
150-
]);
151-
});
152-
}
153-
```
154-
155-
#### Via "viewLogViewer" gate
156-
157-
Another easy way to limit access to the Log Viewer is via [Laravel Gates](https://laravel.com/docs/9.x/authorization#gates). Just define a `viewLogViewer` authorization gate in your `App\Providers\AuthServiceProvider` class:
158-
159-
```php
160-
use App\Models\User;
161-
use Illuminate\Support\Facades\Gate;
162-
163-
/**
164-
* Register any authentication / authorization services.
165-
*
166-
* @return void
167-
*/
168-
public function boot()
169-
{
170-
$this->registerPolicies();
171-
172-
Gate::define('viewLogViewer', function (?User $user) {
173-
// return true if the user is allowed access to the Log Viewer
174-
});
175-
}
176-
```
177-
178-
#### Via middleware
179-
180-
You can easily add [authentication](https://laravel.com/docs/9.x/authentication#protecting-routes) to log viewing routes using popular `auth` middleware in the `config/log-viewer.php`.
181-
182-
If your application doesn't use the default authentication solutions, you can use the `auth.basic` [HTTP Basic Authentication](https://laravel.com/docs/9.x/authentication#http-basic-authentication) middleware.
183-
184-
_**Note:** By default, the `auth.basic` middleware will assume the email column on your users database table is the user's "username"._
185-
186-
See the `auth` middleware configuration below:
187-
```php
188-
/*
189-
|--------------------------------------------------------------------------
190-
| Log Viewer route middleware.
191-
|--------------------------------------------------------------------------
192-
| The middleware should enable session and cookies support in order for the Log Viewer to work.
193-
| The 'web' middleware will be applied automatically if empty.
194-
|
195-
*/
196-
197-
'middleware' => ['web', 'auth'],
198-
```
199-
200-
For authorization using Spatie permissions [see this discussion](https://github.com/opcodesio/log-viewer/discussions/16)
201-
202-
### Authorizing log file download
203-
204-
You can limit the ability to download log files via [Laravel Gates](https://laravel.com/docs/9.x/authorization#gates). Just define a `downloadLogFile` authorization gate in your `App\Providers\AuthServiceProvider` class:
205-
206-
```php
207-
use App\Models\User;
208-
use Opcodes\LogViewer\LogFile;
209-
use Illuminate\Support\Facades\Gate;
210-
211-
/**
212-
* Register any authentication / authorization services.
213-
*
214-
* @return void
215-
*/
216-
public function boot()
217-
{
218-
$this->registerPolicies();
219-
220-
Gate::define('downloadLogFile', function (?User $user, LogFile $file) {
221-
// return true if the user is allowed to download the specific log file.
222-
});
223-
}
224-
```
225-
226-
#### Authorizing folder downloads
227-
228-
You can also limit whether whole folders can be downloaded by defining a `downloadLogFolder` authorization gate:
229-
230-
```php
231-
use Opcodes\LogViewer\LogFolder;
232-
233-
//...
234-
235-
Gate::define('downloadLogFolder', function (?User $user, LogFolder $folder) {
236-
// return true if the user is allowed to download the whole folder.
237-
});
238-
```
239-
240-
**NOTE:** Individual file permissions are also checked before downloading them, to avoid accidental downloads of protected log files.
241-
242-
### Authorizing log file deletion
243-
244-
You can limit the ability to delete log files via [Laravel Gates](https://laravel.com/docs/9.x/authorization#gates). Just define a `deleteLogFile` authorization gate in your `App\Providers\AuthServiceProvider` class:
245-
246-
```php
247-
use App\Models\User;
248-
use Opcodes\LogViewer\LogFile;
249-
use Illuminate\Support\Facades\Gate;
250-
251-
/**
252-
* Register any authentication / authorization services.
253-
*
254-
* @return void
255-
*/
256-
public function boot()
257-
{
258-
$this->registerPolicies();
259-
260-
Gate::define('deleteLogFile', function (?User $user, LogFile $file) {
261-
// return true if the user is allowed to delete the specific log file.
262-
});
263-
}
264-
```
265-
266-
#### Authorizing folder deletion
267-
268-
You can also limit whether whole folders can be deleted by defining a `deleteLogFolder` authorization gate:
269-
270-
```php
271-
use Opcodes\LogViewer\LogFolder;
272-
273-
//...
274-
275-
Gate::define('deleteLogFolder', function (?User $user, LogFolder $folder) {
276-
// return true if the user is allowed to delete the whole folder.
277-
});
278-
```
279-
280-
**NOTE:** Individual file permissions are also checked before deleting them, to avoid accidental deletion of protected log files.
281-
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-
```
71+
Please visit the **[Log Viewer Docs](https://log-viewer.opcodes.io/docs)** to learn about configuring Log Viewer to your needs.
28972

29073
## Troubleshooting
29174

0 commit comments

Comments
 (0)