Skip to content

Commit d3559d1

Browse files
committed
prepare for 1.1.0 release
1 parent 6fa129a commit d3559d1

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

CHANGELOG.md

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

55
- ...
66

7-
## [1.1.0 (2023-07-14)](https://github.com/onlime/laravel-sql-reporter/compare/v1.0.1...v1.1.0)
7+
## [1.1.0 (2023-07-16)](https://github.com/onlime/laravel-sql-reporter/compare/v1.0.1...v1.1.0)
88

9-
- Drop Laravel 9 support, require Laravel v10.15 or higher for the new `DB::getRawQueryLog()` support.
9+
- Drop Laravel 9 support, require Laravel v10.15 or higher for the new [`DB::getRawQueryLog()`](https://github.com/laravel/framework/pull/47507) support.
1010
- PHP code style fixes by `laravel/pint` v1.10, now using more strict style rules (`laravel` preset).
1111
- Refactored whole codebase from `DB::getQueryLog()` to use the new `DB::getRawQueryLog()` method, so `ReplacesBindings` is no longer needed.
1212
- Replaced [torann/geoip](https://github.com/Torann/laravel-geoip) by [stevebauman/location](https://github.com/stevebauman/location) for optional GeoIP support.

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This module allows you to log SQL queries to log file in Laravel framework. It's useful mainly
1010
when developing your application to verify whether your queries are valid and to make sure your application doesn't run too many or too slow database queries.
1111

12-
You may also use this in production as it should not cause a lot of overhead. Logged queries can be limited by query pattern, and logging only occurs at the end of each request or artisan command execution.
12+
You may also use this in production as it should not cause a lot of overhead. Logged queries can be limited by query pattern, and logging only occurs at the end of each request or artisan command execution, not per query execution.
1313

1414
It reports a lot of metadata like total query count, total execution time, origin (request URL/console command), authenticated user, app environment, client browser agent / IP / hostname.
1515

@@ -22,9 +22,9 @@ It reports a lot of metadata like total query count, total execution time, origi
2222
in console to install this module (Notice `--dev` flag - it's recommended to use this package only for development).
2323

2424
Laravel uses package auto-discovery, and it will automatically load this service provider, so you don't need to add anything into the `providers` section of `config/app.php`.
25-
25+
2626
2. Run the following in your console to publish the default configuration file:
27-
27+
2828
```bash
2929
$ php artisan vendor:publish --provider="Onlime\LaravelSqlReporter\Providers\ServiceProvider"
3030
```
@@ -57,11 +57,11 @@ It reports a lot of metadata like total query count, total execution time, origi
5757
SQL_REPORTER_QUERIES_INCLUDE_PATTERN="/^(?!SELECT).*/i"
5858
SQL_REPORTER_QUERIES_EXCLUDE_PATTERN="/^UPDATE.*(last_visit|remember_token)/i"
5959
```
60-
60+
6161
If you have also `.env.example` it's recommended to add those entries also in `.env.example` file just to make sure everyone knows about those env variables. Be aware that `SQL_REPORTER_DIRECTORY` is directory inside storage directory.
62-
62+
6363
To find out more about those setting please take a look at [Configuration file](config/sql-reporter.php)
64-
64+
6565
4. Make sure directory specified in `.env` file exists in storage path, and you have valid permissions to create and modify files in this directory (If it does not exist this package will automatically create it when needed, but it's recommended to create it manually with valid file permissions)
6666

6767
5. Make sure on live server you will set logging SQL queries to false in your `.env` file: `SQL_REPORTER_QUERIES_ENABLED=false`. This package is recommended to be used only for development to not impact production application performance.
@@ -100,7 +100,7 @@ This package was inspired by [mnabialek/laravel-sql-logger](https://github.com/m
100100
101101
- Query logging is not triggered upon each query execution but instead at a final step, using `RequestHandled` and `CommandFinished` events.
102102
- This allows us to include much more information about the whole query executions like total query count, total execution time, and very detailed header information like origin (request URL/console command), authenticated user, app environment, client browser agent / IP / hostname.
103-
- This package is greatly simplified and only provides support for Laravel 8+ / PHP 8
103+
- This package is greatly simplified and only provides support for Laravel 10 / PHP 8.1+
104104
- It uses the Laravel built-in query logging (`DB::enableQueryLog()`) which logs all queries in memory, which should perform much better than writing every single query to the log file.
105105
- By default, `onlime/laravel-sql-reporter` produces much nicer log output, especially since we only write header information before the first query.
106106
@@ -153,12 +153,11 @@ All changes are listed in [CHANGELOG](CHANGELOG.md)
153153
- If your application crashes, this package will not log any queries, as logging is only triggered at the end. As alternative, you could use [mnabialek/laravel-sql-logger](https://github.com/mnabialek/laravel-sql-logger) which triggers sql logging on each query execution.
154154
- It's currently not possible to log slow queries into a separate logfile. I wanted to keep that package simpel.
155155

156-
## Todo
156+
## TODO
157157

158158
- [ ] Improve unit testing to reach 100% coverage
159159
- [ ] Integrate Coveralls.io and add test coverage status badge to README
160-
- [ ] Add browser type information to log headers, using hisorange/browser-detect
161-
- [ ] Support for Lumen
160+
- [ ] Add browser type information to log headers, maybe using [hisorange/browser-detect](https://github.com/hisorange/browser-detect)
162161

163162
## License
164163

src/Formatter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public function getHeader(): string
7272
// (optional) GeoIP lookup if stevebaumann/location is installed, appending country information to IP
7373
if (in_array('ip', $headerFields) && $ip !== '127.0.0.1' && class_exists('Stevebauman\Location\Facades\Location')) {
7474
$position = \Stevebauman\Location\Facades\Location::get();
75-
$headers['ip'] .= sprintf(' (%s / %s)', $position->isoCode, $position->countryName);
75+
$headers['ip'] .= sprintf(
76+
' (%s / %s)',
77+
$position->isoCode ?? 'XX',
78+
$position->countryName ?? 'Unknown Country'
79+
);
7680
}
7781

7882
// get formatted header lines with padded keys

tests/Unit/SqlQueryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tests\Unit;
44

5-
use Illuminate\Support\Carbon;
65
use Onlime\LaravelSqlReporter\SqlQuery;
76

87
class SqlQueryTest extends UnitTestCase

tests/Unit/WriterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class WriterTest extends UnitTestCase
1616
/**
1717
* @var Formatter|\Mockery\Mock
1818
*/
19-
private $formatter;
19+
private $formatter;
2020

2121
/**
2222
* @var Config|\Mockery\Mock

0 commit comments

Comments
 (0)