1313use CodeRhapsodie \DataflowBundle \Logger \DelegatingLogger ;
1414use CodeRhapsodie \DataflowBundle \Registry \DataflowTypeRegistryInterface ;
1515use CodeRhapsodie \DataflowBundle \Repository \JobRepository ;
16+ use League \Flysystem \Filesystem ;
1617use Monolog \Logger ;
1718use Psr \Log \LoggerAwareInterface ;
1819use Psr \Log \LoggerAwareTrait ;
@@ -22,7 +23,12 @@ class JobProcessor implements JobProcessorInterface, LoggerAwareInterface
2223{
2324 use LoggerAwareTrait;
2425
25- public function __construct (private JobRepository $ repository , private DataflowTypeRegistryInterface $ registry , private EventDispatcherInterface $ dispatcher )
26+ public function __construct (
27+ private JobRepository $ repository ,
28+ private DataflowTypeRegistryInterface $ registry ,
29+ private EventDispatcherInterface $ dispatcher ,
30+ private ?Filesystem $ filesystem = null
31+ )
2632 {
2733 }
2834
@@ -69,12 +75,19 @@ private function beforeProcessing(Job $job): void
6975
7076 private function afterProcessing (Job $ job , Result $ result , BufferHandler $ bufferLogger ): void
7177 {
78+ $ exceptions = $ bufferLogger ->clearBuffer ();
79+ if ($ this ->filesystem ) {
80+ $ this ->filesystem ->write (sprintf ('dataflow-job-%s.log ' ,$ job ->getId ()), json_encode ($ exceptions ));
81+ $ exceptions = [];
82+ }
83+
7284 $ job
7385 ->setEndTime ($ result ->getEndTime ())
7486 ->setStatus (Job::STATUS_COMPLETED )
7587 ->setCount ($ result ->getSuccessCount ())
76- ->setExceptions ($ bufferLogger -> clearBuffer () )
88+ ->setExceptions ($ exceptions )
7789 ;
90+
7891 $ this ->repository ->save ($ job );
7992
8093 $ this ->dispatcher ->dispatch (new ProcessingEvent ($ job ), Events::AFTER_PROCESSING );
0 commit comments