Skip to content

Commit

Permalink
Add auth guard to log headers
Browse files Browse the repository at this point in the history
  • Loading branch information
onlime committed Mar 9, 2024
1 parent 922a559 commit 8cff8f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

- ...

## [v1.2.0 (2024-03-09)](https://github.com/onlime/laravel-sql-reporter/compare/v1.1.0...v1.2.0)
## [v1.2.0 (2024-03-11)](https://github.com/onlime/laravel-sql-reporter/compare/v1.1.0...v1.2.0)

- Feature | Dispatch `QueryLogWritten` event after writing queries to the log, so that the whole query log can be accessed for further processing, e.g. generating reports/notifications.
- Feature | Added auth guard to log headers.
- Laravel 11 support

## [v1.1.0 (2023-07-16)](https://github.com/onlime/laravel-sql-reporter/compare/v1.0.1...v1.1.0)
Expand Down
3 changes: 2 additions & 1 deletion config/sql-reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* - datetime: date and time when the first query was executed
* - status: total query count and execution time for all queries
* - user: username of authenticated user
* - guard: name of the auth guard (defaults to 'web' if not logged in)
* - env: application environment
* - agent: user agent
* - ip: (request-only) remote user IP
Expand All @@ -43,7 +44,7 @@
* data if origin is an Artisan command.
*/
'header_fields' => array_filter(explode(',', env('SQL_REPORTER_FORMAT_HEADER_FIELDS',
'origin,datetime,status,user,env,agent,ip,host,referer'
'origin,datetime,status,user,guard,env,agent,ip,host,referer'
))),

/*
Expand Down
1 change: 1 addition & 0 deletions src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getHeader(): string
'origin' => $this->originLine(),
'status' => sprintf('Executed %s queries in %s', count($queryLog), $totalTime),
'user' => $username,
'guard' => Auth::guard()->name,
'env' => $this->app->environment(),
'agent' => Request::userAgent() ?? PHP_SAPI,
'ip' => $ip,
Expand Down

0 comments on commit 8cff8f7

Please sign in to comment.