File tree Expand file tree Collapse file tree 2 files changed +24
-11
lines changed
Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Original file line number Diff line number Diff line change 2222 }
2323 ],
2424 "require" : {
25- "php" : " >=7.2| ^8.0 " ,
26- "illuminate/support" : " ^6.0|^7.0|^8.0|^9.0|^ 10.0" ,
27- "rollbar/rollbar" : " ^2.0 | ^3.1 "
25+ "php" : " ^8.1 " ,
26+ "illuminate/support" : " ^10.0" ,
27+ "rollbar/rollbar" : " ^4.0 "
2828 },
2929 "require-dev" : {
30- "orchestra/testbench" : " ^4.0|^5.0|^6.0|^7 .0" ,
30+ "orchestra/testbench" : " ^8 .0" ,
3131 "mockery/mockery" : " ^1" ,
3232 "php-coveralls/php-coveralls" : " ^2.2" ,
3333 "squizlabs/php_codesniffer" : " 3.*" ,
Original file line number Diff line number Diff line change 33namespace Rollbar \Laravel ;
44
55use Monolog \Handler \RollbarHandler ;
6+ use Monolog \LogRecord ;
67
78class MonologHandler extends RollbarHandler
89{
910 protected $ app ;
1011
12+ /**
13+ * @param $app
14+ * @return void
15+ */
1116 public function setApp ($ app )
1217 {
1318 $ this ->app = $ app ;
1419 }
1520
16- protected function write (array $ record ): void
21+ /**
22+ * @param LogRecord $record
23+ * @return void
24+ */
25+ protected function write (LogRecord $ record ): void
1726 {
18- $ record ['context ' ] = $ this ->addContext ($ record ['context ' ]);
19- parent ::write ($ record );
27+ parent ::write (new LogRecord ($ record ->datetime ,
28+ $ record ->channel ,
29+ $ record ->level ,
30+ $ record ->message ,
31+ $ this ->addContext ($ record ->context ),
32+ $ record ->extra ,
33+ $ record ->formatted ));
2034 }
2135
2236 /**
23- * Add Laravel specific information to the context.
24- *
2537 * @param array $context
38+ * @return array
2639 */
27- protected function addContext (array $ context = [])
40+ protected function addContext (array $ context = []): array
2841 {
2942 $ config = $ this ->rollbarLogger ->extend ([]);
3043
@@ -47,7 +60,7 @@ protected function addContext(array $context = [])
4760 } elseif (method_exists ($ data , 'getKey ' )) {
4861 $ person ['id ' ] = $ data ->getKey ();
4962 }
50-
63+
5164 if (isset ($ person ['id ' ])) {
5265 if (isset ($ data ->username )) {
5366 $ person ['username ' ] = $ data ->username ;
You can’t perform that action at this time.
0 commit comments