Skip to content

Commit

Permalink
[9.x] Update psr/log version (#38852)
Browse files Browse the repository at this point in the history
* Update psr/log

* Add types for LogManager

* Update Logger typing
  • Loading branch information
kylekatarnls authored Sep 18, 2021
1 parent b0a0d66 commit 2b2420b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"nesbot/carbon": "^2.31",
"opis/closure": "^3.6",
"psr/container": "^1.1.1|^2.0.1",
"psr/log": "^3.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^4.0",
"symfony/console": "^6.0",
Expand Down
19 changes: 10 additions & 9 deletions src/Illuminate/Log/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Monolog\Handler\WhatFailureGroupHandler;
use Monolog\Logger as Monolog;
use Psr\Log\LoggerInterface;
use Stringable;
use Throwable;

class LogManager implements LoggerInterface
Expand Down Expand Up @@ -521,7 +522,7 @@ protected function parseDriver($driver)
* @param array $context
* @return void
*/
public function emergency($message, array $context = [])
public function emergency(string|Stringable $message, array $context = []): void
{
$this->driver()->emergency($message, $context);
}
Expand All @@ -536,7 +537,7 @@ public function emergency($message, array $context = [])
* @param array $context
* @return void
*/
public function alert($message, array $context = [])
public function alert(string|Stringable $message, array $context = []): void
{
$this->driver()->alert($message, $context);
}
Expand All @@ -550,7 +551,7 @@ public function alert($message, array $context = [])
* @param array $context
* @return void
*/
public function critical($message, array $context = [])
public function critical(string|Stringable $message, array $context = []): void
{
$this->driver()->critical($message, $context);
}
Expand All @@ -563,7 +564,7 @@ public function critical($message, array $context = [])
* @param array $context
* @return void
*/
public function error($message, array $context = [])
public function error(string|Stringable $message, array $context = []): void
{
$this->driver()->error($message, $context);
}
Expand All @@ -578,7 +579,7 @@ public function error($message, array $context = [])
* @param array $context
* @return void
*/
public function warning($message, array $context = [])
public function warning(string|Stringable $message, array $context = []): void
{
$this->driver()->warning($message, $context);
}
Expand All @@ -590,7 +591,7 @@ public function warning($message, array $context = [])
* @param array $context
* @return void
*/
public function notice($message, array $context = [])
public function notice(string|Stringable $message, array $context = []): void
{
$this->driver()->notice($message, $context);
}
Expand All @@ -604,7 +605,7 @@ public function notice($message, array $context = [])
* @param array $context
* @return void
*/
public function info($message, array $context = [])
public function info(string|Stringable $message, array $context = []): void
{
$this->driver()->info($message, $context);
}
Expand All @@ -616,7 +617,7 @@ public function info($message, array $context = [])
* @param array $context
* @return void
*/
public function debug($message, array $context = [])
public function debug(string|Stringable $message, array $context = []): void
{
$this->driver()->debug($message, $context);
}
Expand All @@ -629,7 +630,7 @@ public function debug($message, array $context = [])
* @param array $context
* @return void
*/
public function log($level, $message, array $context = [])
public function log($level, string|Stringable $message, array $context = []): void
{
$this->driver()->log($level, $message, $context);
}
Expand Down
21 changes: 11 additions & 10 deletions src/Illuminate/Log/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Log\Events\MessageLogged;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Stringable;

class Logger implements LoggerInterface
{
Expand Down Expand Up @@ -53,7 +54,7 @@ public function __construct(LoggerInterface $logger, Dispatcher $dispatcher = nu
* @param array $context
* @return void
*/
public function emergency($message, array $context = [])
public function emergency(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -65,7 +66,7 @@ public function emergency($message, array $context = [])
* @param array $context
* @return void
*/
public function alert($message, array $context = [])
public function alert(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -77,7 +78,7 @@ public function alert($message, array $context = [])
* @param array $context
* @return void
*/
public function critical($message, array $context = [])
public function critical(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -89,7 +90,7 @@ public function critical($message, array $context = [])
* @param array $context
* @return void
*/
public function error($message, array $context = [])
public function error(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -101,7 +102,7 @@ public function error($message, array $context = [])
* @param array $context
* @return void
*/
public function warning($message, array $context = [])
public function warning(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -113,7 +114,7 @@ public function warning($message, array $context = [])
* @param array $context
* @return void
*/
public function notice($message, array $context = [])
public function notice(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -125,7 +126,7 @@ public function notice($message, array $context = [])
* @param array $context
* @return void
*/
public function info($message, array $context = [])
public function info(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -137,7 +138,7 @@ public function info($message, array $context = [])
* @param array $context
* @return void
*/
public function debug($message, array $context = [])
public function debug(string|Stringable $message, array $context = []): void
{
$this->writeLog(__FUNCTION__, $message, $context);
}
Expand All @@ -150,7 +151,7 @@ public function debug($message, array $context = [])
* @param array $context
* @return void
*/
public function log($level, $message, array $context = [])
public function log($level, string|Stringable $message, array $context = []): void
{
$this->writeLog($level, $message, $context);
}
Expand All @@ -163,7 +164,7 @@ public function log($level, $message, array $context = [])
* @param array $context
* @return void
*/
public function write($level, $message, array $context = [])
public function write($level, string|Stringable $message, array $context = []): void
{
$this->writeLog($level, $message, $context);
}
Expand Down

0 comments on commit 2b2420b

Please sign in to comment.