Skip to content

Commit 6907ee8

Browse files
committed
update readme for Laravel 12 integration
1 parent f3b355d commit 6907ee8

File tree

2 files changed

+54
-26
lines changed

2 files changed

+54
-26
lines changed

README.md

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Laravel DevLogger Package
2+
23
[![Packagist License](https://img.shields.io/badge/Licence-MIT-blue)](http://choosealicense.com/licenses/mit/)
34

4-
`DevLogger` is a comprehensive logging package for Laravel that stores logs in a database with automatic error catching, advanced filtering, and management capabilities.
5+
`DevLogger` is a comprehensive logging package for Laravel that stores logs in a database with automatic error catching,
6+
advanced filtering, and management capabilities.
57

68
## Features
79

@@ -102,9 +104,10 @@ try {
102104
}
103105
```
104106

105-
### Automatic Exception Catching
107+
### Automatic Exception Catching - Laravel 9, 10, 11
106108

107-
The package automatically catches and logs all unhandled exceptions when `DEVLOGGER_AUTO_CATCH=true` (default). To set this up:
109+
The package automatically catches and logs all unhandled exceptions when `DEVLOGGER_AUTO_CATCH=true` (default). To set
110+
this up:
108111

109112
#### Option 1: Extend the DevLogger Exception Handler
110113

@@ -144,6 +147,31 @@ public function report(Throwable $exception)
144147
}
145148
```
146149

150+
### Automatic Exception Catching - Laravel 12
151+
152+
#### Integration
153+
154+
The bootstrap directory contains the app.php file which bootstraps the framework: `bootstrap/app.php`. Within the
155+
withException method, you can integrate the DevLogger package to automatically catch exceptions:
156+
157+
```php
158+
159+
->withExceptions(function (Exceptions $exceptions) {
160+
161+
$exceptions->report(function (Throwable $e){
162+
if (config('devlogger.auto_catch_exceptions', true)) {
163+
\DevLoggertPackage\Facades\DevLogger::logException($e, [
164+
'url' => request()?->fullUrl(),
165+
'method' => request()?->method(),
166+
'input' => request()?->except(['password', 'password_confirmation', '_token']),
167+
]);
168+
}
169+
return true;
170+
})
171+
172+
})->create();
173+
```
174+
147175
## Advanced Usage
148176

149177
### Working with Log Models
@@ -187,28 +215,28 @@ Automatic cleanup runs daily when `DEVLOGGER_RETENTION_DAYS` is configured.
187215

188216
The `developer_logs` table includes these fields:
189217

190-
| Field | Type | Description |
191-
|-------|------|-------------|
192-
| `id` | bigint | Primary key |
193-
| `level` | string | Log level (debug, info, error, etc.) |
194-
| `log` | longtext | The log message |
195-
| `context` | json | Additional context data |
196-
| `file_path` | string | File where log originated |
197-
| `line_number` | integer | Line number where log originated |
198-
| `exception_class` | string | Exception class name (for exceptions) |
199-
| `stack_trace` | longtext | Full stack trace (for exceptions) |
200-
| `queue` | string | Associated queue name |
201-
| `request_url` | string | HTTP request URL |
202-
| `request_method` | string | HTTP request method |
203-
| `user_id` | bigint | ID of authenticated user |
204-
| `ip_address` | string | Client IP address |
205-
| `user_agent` | text | Client user agent |
206-
| `status` | string | Log status (open/closed) |
207-
| `tags` | json | Array of tags |
208-
| `updated_by` | bigint | User who last updated the log |
209-
| `created_at` | timestamp | When log was created |
210-
| `updated_at` | timestamp | When log was last updated |
211-
| `deleted_at` | timestamp | Soft delete timestamp |
218+
| Field | Type | Description |
219+
|-------------------|-----------|---------------------------------------|
220+
| `id` | bigint | Primary key |
221+
| `level` | string | Log level (debug, info, error, etc.) |
222+
| `log` | longtext | The log message |
223+
| `context` | json | Additional context data |
224+
| `file_path` | string | File where log originated |
225+
| `line_number` | integer | Line number where log originated |
226+
| `exception_class` | string | Exception class name (for exceptions) |
227+
| `stack_trace` | longtext | Full stack trace (for exceptions) |
228+
| `queue` | string | Associated queue name |
229+
| `request_url` | string | HTTP request URL |
230+
| `request_method` | string | HTTP request method |
231+
| `user_id` | bigint | ID of authenticated user |
232+
| `ip_address` | string | Client IP address |
233+
| `user_agent` | text | Client user agent |
234+
| `status` | string | Log status (open/closed) |
235+
| `tags` | json | Array of tags |
236+
| `updated_by` | bigint | User who last updated the log |
237+
| `created_at` | timestamp | When log was created |
238+
| `updated_at` | timestamp | When log was last updated |
239+
| `deleted_at` | timestamp | Soft delete timestamp |
212240

213241
## Configuration Options
214242

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onamfc/laravel-devlogger",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "A custom logging package for Laravel with database storage and automatic error catching",
55
"type": "library",
66
"keywords": ["laravel", "logging", "database", "error-handling"],

0 commit comments

Comments
 (0)