Skip to content

Commit

Permalink
Merge branch 'code-style-fixes-laravel-58' into laravel-58
Browse files Browse the repository at this point in the history
  • Loading branch information
dejwCake committed Aug 27, 2019
2 parents 5e6a9fa + 1118f7e commit 100177d
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 57 deletions.
2 changes: 1 addition & 1 deletion config/advanced-logger.php
Expand Up @@ -63,4 +63,4 @@

'benchmark' => 'application',
],
];
];
2 changes: 1 addition & 1 deletion src/AdvancedLoggerServiceProvider.php
Expand Up @@ -37,4 +37,4 @@ public function register(): void
$this->mergeConfigFrom(__DIR__ . '/../config/advanced-logger.php', 'advanced-logger');
Benchmark::start(config('advanced-logger.request.benchmark', 'application'));
}
}
}
2 changes: 1 addition & 1 deletion src/Contracts/InterpolationContract.php
Expand Up @@ -12,4 +12,4 @@ interface InterpolationContract
* @return string
*/
public function interpolate(string $text): string;
}
}
9 changes: 6 additions & 3 deletions src/Formatters/LineWithHashFormatter.php
Expand Up @@ -20,8 +20,11 @@ public function format(array $record)
{
$output = parent::format($record);
if (false !== strpos($output, '%' . self::KEY . '%')) {
$output = str_replace('%' . self::KEY . '%',
$this->stringify($this->getRequestHash()), $output);
$output = str_replace(
'%' . self::KEY . '%',
$this->stringify($this->getRequestHash()),
$output
);
}
return $output;
}
Expand All @@ -39,4 +42,4 @@ protected function getRequestHash(): ?string
return null;
}
}
}
}
8 changes: 5 additions & 3 deletions src/Handlers/RequestLoggerHandler.php
Expand Up @@ -28,8 +28,10 @@ public function __construct(
$filePermission = null,
$useLocking = false
) {
$filename = !is_null($filename) ? $filename : config('advanced-logger.request.file',
storage_path('logs/request.log'));
$filename = !is_null($filename) ? $filename : config(
'advanced-logger.request.file',
storage_path('logs/request.log')
);
parent::__construct($filename, $maxFiles, $level, $bubble, $filePermission, $useLocking);
}
}
}
2 changes: 1 addition & 1 deletion src/Interpolations/BaseInterpolation.php
Expand Up @@ -86,4 +86,4 @@ protected function formatSizeUnits(int $bytes): string

return $bytes;
}
}
}
4 changes: 2 additions & 2 deletions src/Interpolations/RequestInterpolation.php
Expand Up @@ -110,7 +110,7 @@ protected function resolveVariable(string $raw, string $variable): string
return $this->convertToString($this->request->header(strtolower($option)));
case 'server':
return $this->convertToString($this->request->server($option));
default;
default:
return $raw;
}
}
Expand Down Expand Up @@ -147,4 +147,4 @@ protected function getUser(): ?string
return null;
}
}
}
}
4 changes: 2 additions & 2 deletions src/Interpolations/ResponseInterpolation.php
Expand Up @@ -65,7 +65,7 @@ protected function resolveVariable(string $raw, string $variable): string
switch (strtolower($var)) {
case 'res':
return $this->convertToString($this->response->headers->get($option));
default;
default:
return $raw;
}
}
Expand Down Expand Up @@ -123,4 +123,4 @@ protected function getRequestHash(): ?string
return null;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Jobs/RequestLogJob.php
Expand Up @@ -46,4 +46,4 @@ public function handle(): void
$requestLoggerService = app(RequestLoggerService::class);
$requestLoggerService->log($this->request, $this->response);
}
}
}
10 changes: 6 additions & 4 deletions src/LogCustomizers/HashLogCustomizer.php
Expand Up @@ -12,14 +12,16 @@ class HashLogCustomizer
/**
* Customize the given logger instance.
*
* @param \Illuminate\Log\Logger $logger
* @param \Illuminate\Log\Logger $logger
* @return void
*/
public function __invoke($logger)
{
foreach ($logger->getHandlers() as $handler) {
$handler->setFormatter(app(LineWithHashFormatter::class,
['format' => "[%datetime%] %hash% %channel%.%level_name%: %message% %context% %extra%\n"]));
$handler->setFormatter(app(
LineWithHashFormatter::class,
['format' => "[%datetime%] %hash% %channel%.%level_name%: %message% %context% %extra%\n"]
));
}
}
}
}
64 changes: 32 additions & 32 deletions src/Loggers/RequestLogger.php
Expand Up @@ -42,83 +42,83 @@ public function __construct()
/**
* Log an alert message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function alert($message, array $context = array())
public function alert($message, array $context = [])
{
$this->monolog->alert($message, $context);
}

/**
* Log a critical message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function critical($message, array $context = array())
public function critical($message, array $context = [])
{
$this->monolog->critical($message, $context);
}

/**
* Log an error message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function error($message, array $context = array())
public function error($message, array $context = [])
{
$this->monolog->error($message, $context);
}

/**
* Log a warning message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function warning($message, array $context = array())
public function warning($message, array $context = [])
{
$this->monolog->warning($message, $context);
}

/**
* Log a notice to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function notice($message, array $context = array())
public function notice($message, array $context = [])
{
$this->monolog->notice($message, $context);
}

/**
* Log an informational message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function info($message, array $context = array())
public function info($message, array $context = [])
{
$this->monolog->info($message, $context);
}

/**
* Log a debug message to the logs.
*
* @param string $message
* @param array $context
* @param string $message
* @param array $context
* @return void
*/
public function debug($message, array $context = array())
public function debug($message, array $context = [])
{
$this->monolog->debug($message, $context);
}
Expand All @@ -131,29 +131,29 @@ public function debug($message, array $context = array())
* @param array $context
* @return void
*/
public function emergency($message, array $context = array())
public function emergency($message, array $context = [])
{
$this->monolog->emergency($message, $context);
}

/**
* Log a message to the logs.
*
* @param string $level
* @param string $message
* @param array $context
* @param string $level
* @param string $message
* @param array $context
* @return void
*/
public function log($level, $message, array $context = array())
public function log($level, $message, array $context = [])
{
$this->monolog->log($level, $message, $context);
}

/**
* Register a file log handler.
*
* @param string $path
* @param string $level
* @param string $path
* @param string $level
* @return void
*/
public function useFiles($path, $level = 'debug')
Expand All @@ -163,12 +163,12 @@ public function useFiles($path, $level = 'debug')
/**
* Register a daily file log handler.
*
* @param string $path
* @param int $days
* @param string $level
* @param string $path
* @param int $days
* @param string $level
* @return void
*/
public function useDailyFiles($path, $days = 0, $level = 'debug')
{
}
}
}
2 changes: 1 addition & 1 deletion src/Services/Benchmark.php
Expand Up @@ -79,4 +79,4 @@ public static function generateRandomHash()
return substr(sha1(time()), 0, 10);
}
}
}
}
3 changes: 1 addition & 2 deletions src/Services/RequestLoggerService.php
Expand Up @@ -80,5 +80,4 @@ public function log(Request $request, Response $response): void
]);
}
}

}
}
4 changes: 2 additions & 2 deletions tests/Feature/RequestLoggerTest.php
Expand Up @@ -8,7 +8,7 @@ class RequestLoggerTest extends TestCase
{

/** @test */
function request_is_logged_in_file()
public function request_is_logged_in_file()
{
$response = $this->get('/');
$response->assertStatus(200);
Expand All @@ -17,7 +17,7 @@ function request_is_logged_in_file()
}

/** @test */
function excluded_path_is_not_logged()
public function excluded_path_is_not_logged()
{
$response = $this->get('/excluded');
$response->assertStatus(200);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Expand Up @@ -80,4 +80,4 @@ protected function getPackageProviders($app): array
AdvancedLoggerServiceProvider::class,
];
}
}
}

0 comments on commit 100177d

Please sign in to comment.