@@ -68,7 +68,7 @@ public function bootstrap(Application $app)
68
68
public function handleError ($ level , $ message , $ file = '' , $ line = 0 , $ context = [])
69
69
{
70
70
if ($ this ->isDeprecation ($ level )) {
71
- return $ this ->handleDeprecation ($ message , $ file , $ line );
71
+ return $ this ->handleDeprecationError ($ message , $ file , $ line, $ level );
72
72
}
73
73
74
74
if (error_reporting () & $ level ) {
@@ -83,8 +83,24 @@ public function handleError($level, $message, $file = '', $line = 0, $context =
83
83
* @param string $file
84
84
* @param int $line
85
85
* @return void
86
+ *
87
+ * @deprecated Use handleDeprecationError instead.
86
88
*/
87
89
public function handleDeprecation ($ message , $ file , $ line )
90
+ {
91
+ $ this ->handleDeprecationError ($ message , $ file , $ line );
92
+ }
93
+
94
+ /**
95
+ * Reports a deprecation to the "deprecations" logger.
96
+ *
97
+ * @param string $message
98
+ * @param string $file
99
+ * @param int $line
100
+ * @param int $level
101
+ * @return void
102
+ */
103
+ public function handleDeprecationError ($ message , $ file , $ line , $ level = E_DEPRECATED )
88
104
{
89
105
if (! class_exists (LogManager::class)
90
106
|| ! static ::$ app ->hasBeenBootstrapped ()
@@ -101,8 +117,16 @@ public function handleDeprecation($message, $file, $line)
101
117
102
118
$ this ->ensureDeprecationLoggerIsConfigured ();
103
119
104
- with ($ logger ->channel ('deprecations ' ), function ($ log ) use ($ message , $ file , $ line ) {
105
- $ log ->warning ((string ) new ErrorException ($ message , 0 , E_DEPRECATED , $ file , $ line ));
120
+ $ options = static ::$ app ['config ' ]->get ('logging.deprecations ' ) ?? [];
121
+
122
+ with ($ logger ->channel ('deprecations ' ), function ($ log ) use ($ message , $ file , $ line , $ level , $ options ) {
123
+ if ($ options ['trace ' ] ?? false ) {
124
+ $ log ->warning ((string ) new ErrorException ($ message , 0 , $ level , $ file , $ line ));
125
+ } else {
126
+ $ log ->warning (sprintf ('%s in %s on line %s ' ,
127
+ $ message , $ file , $ line
128
+ ));
129
+ }
106
130
});
107
131
}
108
132
@@ -120,7 +144,9 @@ protected function ensureDeprecationLoggerIsConfigured()
120
144
121
145
$ this ->ensureNullLogDriverIsConfigured ();
122
146
123
- $ driver = $ config ->get ('logging.deprecations ' ) ?? 'null ' ;
147
+ $ options = $ config ->get ('logging.deprecations ' );
148
+
149
+ $ driver = is_array ($ options ) ? $ options ['channel ' ] : ($ options ?? 'null ' );
124
150
125
151
$ config ->set ('logging.channels.deprecations ' , $ config ->get ("logging.channels. {$ driver }" ));
126
152
});
0 commit comments