@@ -23,24 +23,27 @@ public function __construct(LoggerInterface $logger, Action $action)
2323
2424 public function handle (Envelope $ envelope , StackInterface $ stack ): Envelope
2525 {
26- $ message = $ this -> messageFromEnvelope ( $ envelope );
26+ $ message = $ envelope -> getMessage ( );
2727 $ context = [
2828 'message ' => $ message ,
29- 'name ' => $ message ::messageName (),
3029 'retry_count ' => $ this ->extractEnvelopeRetryCount ($ envelope ),
3130 ];
3231
32+ $ messageName = $ message instanceof Message
33+ ? $ message ::messageName ()
34+ : '' ;
35+
3336 try {
3437 $ result = $ stack ->next ()->handle ($ envelope , $ stack );
3538 $ this ->logger ->info (
36- $ this ->action ->success () . ' "{name}" ' ,
37- $ context
39+ \sprintf ( ' %s "%s" ' , $ this ->action ->success (), $ messageName ) ,
40+ $ context,
3841 );
3942 } catch (\Throwable $ e ) {
4043 $ context ['exception ' ] = $ e ;
4144 $ this ->logger ->error (
42- $ this ->action ->error () . ' "{name}" ' ,
43- $ context
45+ \sprintf ( ' %s "%s" ' , $ this ->action ->error (), $ messageName ) ,
46+ $ context,
4447 );
4548
4649 throw $ e ;
@@ -49,15 +52,12 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
4952 return $ result ;
5053 }
5154
52- private function messageFromEnvelope (Envelope $ envelope ): Message
53- {
54- return $ envelope ->getMessage ();
55- }
56-
5755 private function extractEnvelopeRetryCount (Envelope $ envelope ): int
5856 {
5957 $ retryCountStamp = $ envelope ->last (RedeliveryStamp::class);
60-
61- return null !== $ retryCountStamp ? $ retryCountStamp ->getRetryCount () : 0 ;
58+
59+ return null !== $ retryCountStamp
60+ ? $ retryCountStamp ->getRetryCount ()
61+ : 0 ;
6262 }
6363}
0 commit comments