Skip to content

Commit

Permalink
Laravel 10
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Feb 15, 2023
1 parent be8f988 commit f9cf0b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
12 changes: 0 additions & 12 deletions .php-cs-fixer.php

This file was deleted.

13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"description": "A dev tool to log all queries for laravel application.",
"type": "library",
"require": {
"laravel/framework": "^9.0"
"laravel/framework": "^9.0|^10.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0"
"laravel/pint": "^1.5",
"brainmaestro/composer-git-hooks": "dev-master"
},
"autoload": {
"psr-4": {
Expand All @@ -28,11 +29,9 @@
},
"hooks": {
"pre-commit": [
"composer test",
"composer fix-style"
"composer check-style"
],
"pre-push": [
"composer test",
"composer check-style"
]
}
Expand All @@ -47,8 +46,8 @@
"cghooks update"
],
"cghooks": "vendor/bin/cghooks",
"check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --ansi",
"fix-style": "php-cs-fixer fix --using-cache=no --ansi",
"check-style": "vendor/bin/pint --test",
"fix-style": "vendor/bin/pint",
"test": "vendor/bin/phpunit --colors=always"
},
"scripts-descriptions": {
Expand Down
11 changes: 4 additions & 7 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Overtrue\LaravelQueryLogger;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;

Expand All @@ -23,13 +22,13 @@ class ServiceProvider extends LaravelServiceProvider
*/
public function boot()
{
if (!$this->app['config']->get('logging.query.enabled', false)) {
if (! $this->app['config']->get('logging.query.enabled', false)) {
return;
}

$trigger = $this->app['config']->get('logging.query.trigger');

if (!empty($trigger) && !$this->requestHasTrigger($trigger)) {
if (! empty($trigger) && ! $this->requestHasTrigger($trigger)) {
return;
}

Expand All @@ -50,7 +49,7 @@ public function boot()
}
Log::channel(config('logging.query.channel', config('logging.default')))
->debug(sprintf('[%s] [%s] %s | %s: %s', $query->connection->getDatabaseName(), $duration, $realSql,
request()->method(), request()->getRequestUri()));
request()->method(), request()->getRequestUri()));
});
}

Expand All @@ -62,8 +61,7 @@ public function register()
}

/**
* @param string $trigger
*
* @param string $trigger
* @return bool
*/
public function requestHasTrigger($trigger)
Expand All @@ -75,7 +73,6 @@ public function requestHasTrigger($trigger)
* Format duration.
*
* @param float $seconds
*
* @return string
*/
private function formatDuration($seconds)
Expand Down

0 comments on commit f9cf0b6

Please sign in to comment.