Skip to content

Commit

Permalink
Merge pull request #12 from BRACKETS-by-TRIAD/feature/update-L-10
Browse files Browse the repository at this point in the history
Feature/update l 10
  • Loading branch information
rastik1584 authored Aug 31, 2023
2 parents 15a9a3c + 8a12046 commit 09ca57c
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 69 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
.DS_Store
.phpunit.result.cache
.idea
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
}
],
"require": {
"php": "^8.0.2",
"illuminate/support": "^9.0",
"illuminate/http": "^9.0",
"monolog/monolog": "^1.12|^2.0",
"php": "^8.0|^8.1",
"illuminate/support": "^9.0|^10.0",
"illuminate/http": "^9.0|^10.0",
"monolog/monolog": "^2.9|^3.3",
"ext-json": "*"
},
"require-dev": {
"laravel/framework": "^9.0",
"phpunit/phpunit": "^8.5|^9.0",
"orchestra/testbench": "~7.0"
"laravel/framework": "^9.0|^10.0",
"phpunit/phpunit": "^9.5|^10.0",
"orchestra/testbench": "~8.0"
},
"autoload": {
"classmap": [],
Expand Down
42 changes: 17 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Formatters/LineWithHashFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LineWithHashFormatter extends LineFormatter
public function format(array $record): string
{
$output = parent::format($record);
if (false !== strpos($output, '%' . self::KEY . '%')) {
if (str_contains($output, '%' . self::KEY . '%')) {
$output = str_replace(
'%' . self::KEY . '%',
$this->stringify($this->getRequestHash()),
Expand Down
6 changes: 4 additions & 2 deletions src/Jobs/RequestLogJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
class RequestLogJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* @var Request
*/
protected $request;

protected Request $request;
/**
* @var Response
*/
protected $response;
protected Response $response;

/**
* RequestLogJob constructor.
Expand Down
5 changes: 3 additions & 2 deletions src/LogCustomizers/HashLogCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Brackets\AdvancedLogger\LogCustomizers;

use Brackets\AdvancedLogger\Formatters\LineWithHashFormatter;
use \Illuminate\Log\Logger;

/**
* Class HashLogCustomizer
Expand All @@ -12,10 +13,10 @@ class HashLogCustomizer
/**
* Customize the given logger instance.
*
* @param \Illuminate\Log\Logger $logger
* @param Logger $logger
* @return void
*/
public function __invoke($logger)
public function __invoke(Logger $logger): void
{
foreach ($logger->getHandlers() as $handler) {
$handler->setFormatter(app(
Expand Down
25 changes: 1 addition & 24 deletions src/Loggers/RequestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RequestLogger implements LoggerInterface
/**
* @var \Monolog\Logger;
*/
protected $monolog;
protected \Monolog\Logger $monolog;

/**
* BaseRequestLogger constructor.
Expand Down Expand Up @@ -148,27 +148,4 @@ public function log($level, string|\Stringable $message, array $context = []): v
{
$this->monolog->log($level, $message, $context);
}

/**
* Register a file log handler.
*
* @param string $path
* @param string $level
* @return void
*/
public function useFiles($path, $level = 'debug')
{
}

/**
* Register a daily file log handler.
*
* @param string $path
* @param int $days
* @param string $level
* @return void
*/
public function useDailyFiles($path, $days = 0, $level = 'debug')
{
}
}
6 changes: 3 additions & 3 deletions src/Services/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class Benchmark
/**
* @var array
*/
protected static $timers = [];
protected static array $timers = [];

/**
* @param string $name
* @return mixed
*/
public static function start(string $name)
public static function start(string $name): mixed
{
$start = microtime(true);
static::$timers[$name] = [
Expand Down Expand Up @@ -71,7 +71,7 @@ public static function hash(string $name): string
/**
* @return bool|string
*/
public static function generateRandomHash()
public static function generateRandomHash(): string
{
try {
return substr(str_replace(['+', '/', '='], '', base64_encode(random_bytes(32))), 0, 10);
Expand Down
8 changes: 4 additions & 4 deletions src/Services/RequestLoggerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RequestLoggerService
/**
* @var array
*/
protected $formats = [
protected array $formats = [
'full' => '{request-hash} | HTTP/{http-version} {status} | {remote-addr} | {user} | {method} {url} {query} | {response-time} s | {user-agent} | {referer}',
'combined' => '{remote-addr} - {remote-user} [{date}] "{method} {url} HTTP/{http-version}" {status} {content-length} "{referer}" "{user-agent}"',
'common' => '{remote-addr} - {remote-user} [{date}] "{method} {url} HTTP/{http-version}" {status} {content-length}',
Expand All @@ -32,15 +32,15 @@ class RequestLoggerService
/**
* @var RequestInterpolation
*/
protected $requestInterpolation;
protected RequestInterpolation $requestInterpolation;
/**
* @var ResponseInterpolation
*/
protected $responseInterpolation;
protected ResponseInterpolation $responseInterpolation;
/**
* @var RequestLogger
*/
protected $logger;
protected RequestLogger $logger;

/**
* RequestLoggerService constructor.
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function tearDown(): void
/**
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
if (file_exists($this->getRequestLogFileName())) {
unlink($this->getRequestLogFileName());
Expand Down

0 comments on commit 09ca57c

Please sign in to comment.