1515use Psr \Log \InvalidArgumentException ;
1616use Psr \Log \LoggerInterface ;
1717use Psr \Log \LogLevel ;
18+ use Stringable ;
1819use Throwable ;
1920use function array_key_exists ;
2021use function array_merge ;
@@ -27,14 +28,14 @@ public function __construct(
2728
2829 public static function logLevelToInt (string $ level ): int {
2930 return match ($ level ) {
30- LogLevel::ALERT => ILogger::ERROR ,
31- LogLevel::CRITICAL => ILogger::ERROR ,
32- LogLevel::DEBUG => ILogger::DEBUG ,
3331 LogLevel::EMERGENCY => ILogger::FATAL ,
34- LogLevel::ERROR => ILogger:: ERROR ,
35- LogLevel::INFO => ILogger:: INFO ,
36- LogLevel::NOTICE => ILogger::INFO ,
32+ LogLevel::ALERT ,
33+ LogLevel::ERROR ,
34+ LogLevel::CRITICAL => ILogger::ERROR ,
3735 LogLevel::WARNING => ILogger::WARN ,
36+ LogLevel::INFO ,
37+ LogLevel::NOTICE => ILogger::INFO ,
38+ LogLevel::DEBUG => ILogger::DEBUG ,
3839 default => throw new InvalidArgumentException ('Unsupported custom log level ' ),
3940 };
4041 }
@@ -50,10 +51,9 @@ private function containsThrowable(array $context): bool {
5051 /**
5152 * System is unusable.
5253 *
53- * @param $message
5454 * @param mixed[] $context
5555 */
56- public function emergency ($ message , array $ context = []): void {
56+ public function emergency (string | Stringable $ message , array $ context = []): void {
5757 $ this ->log (LogLevel::EMERGENCY , (string )$ message , $ context );
5858 }
5959
@@ -63,10 +63,9 @@ public function emergency($message, array $context = []): void {
6363 * Example: Entire website down, database unavailable, etc. This should
6464 * trigger the SMS alerts and wake you up.
6565 *
66- * @param $message
6766 * @param mixed[] $context
6867 */
69- public function alert ($ message , array $ context = []): void {
68+ public function alert (string | Stringable $ message , array $ context = []): void {
7069 $ this ->log (LogLevel::ALERT , (string )$ message , $ context );
7170 }
7271
@@ -75,21 +74,19 @@ public function alert($message, array $context = []): void {
7574 *
7675 * Example: Application component unavailable, unexpected exception.
7776 *
78- * @param $message
7977 * @param mixed[] $context
8078 */
81- public function critical ($ message , array $ context = []): void {
79+ public function critical (string | Stringable $ message , array $ context = []): void {
8280 $ this ->log (LogLevel::CRITICAL , (string )$ message , $ context );
8381 }
8482
8583 /**
8684 * Runtime errors that do not require immediate action but should typically
8785 * be logged and monitored.
8886 *
89- * @param $message
9087 * @param mixed[] $context
9188 */
92- public function error ($ message , array $ context = []): void {
89+ public function error (string | Stringable $ message , array $ context = []): void {
9390 $ this ->log (LogLevel::ERROR , (string )$ message , $ context );
9491 }
9592
@@ -99,20 +96,18 @@ public function error($message, array $context = []): void {
9996 * Example: Use of deprecated APIs, poor use of an API, undesirable things
10097 * that are not necessarily wrong.
10198 *
102- * @param $message
10399 * @param mixed[] $context
104100 */
105- public function warning ($ message , array $ context = []): void {
101+ public function warning (string | Stringable $ message , array $ context = []): void {
106102 $ this ->log (LogLevel::WARNING , (string )$ message , $ context );
107103 }
108104
109105 /**
110106 * Normal but significant events.
111107 *
112- * @param $message
113108 * @param mixed[] $context
114109 */
115- public function notice ($ message , array $ context = []): void {
110+ public function notice (string | Stringable $ message , array $ context = []): void {
116111 $ this ->log (LogLevel::NOTICE , (string )$ message , $ context );
117112 }
118113
@@ -121,28 +116,25 @@ public function notice($message, array $context = []): void {
121116 *
122117 * Example: User logs in, SQL logs.
123118 *
124- * @param $message
125119 * @param mixed[] $context
126120 */
127- public function info ($ message , array $ context = []): void {
121+ public function info (string | Stringable $ message , array $ context = []): void {
128122 $ this ->log (LogLevel::INFO , (string )$ message , $ context );
129123 }
130124
131125 /**
132126 * Detailed debug information.
133127 *
134- * @param $message
135128 * @param mixed[] $context
136129 */
137- public function debug ($ message , array $ context = []): void {
130+ public function debug (string | Stringable $ message , array $ context = []): void {
138131 $ this ->log (LogLevel::DEBUG , (string )$ message , $ context );
139132 }
140133
141134 /**
142135 * Logs with an arbitrary level.
143136 *
144137 * @param mixed $level
145- * @param $message
146138 * @param mixed[] $context
147139 *
148140 * @throws InvalidArgumentException
0 commit comments