Пример #1
0
 /**
  * Execute a database transaction
  *
  * @param callable $callback
  * @param callable $errorCallback (optional)
  * @return mixed
  */
 protected function dbTrans(callable $callback, callable $errorCallback = null, array $errorContext = null)
 {
     try {
         return DB::transaction($callback);
     } catch (\Exception $e) {
         Log::log(LogLevel::ERROR, $e->getMessage(), $errorContext);
         if (!empty($errorCallback)) {
             $errorCallback($e);
         } else {
             throw $e;
         }
     }
 }
 public function init()
 {
     $provider = Logger::getProvider();
     //mando i log di tipo NOTICE a Jarvis tramite un processo in coda
     $provider->setHandler('notice', function (array $record) {
         $params = ['message' => $record['message']];
         //manda in coda il processo di invio messaggio a Jarvis
         $this->pushInQueue('SendJarvisLogJob', $params, 'comunications');
     });
     //mando i log di tipo ERROR tramite email agli sviluppatori
     $provider->setHandler('error', function (array $record) {
         $params = ['subject' => 'Errore JST', 'body' => ''];
         //invia email del report errore agli sviluppatori
         $this->pushInQueue('SendEmailJob', $params, 'comunications');
     });
 }
Пример #3
0
 /**
  * Ritorna il contesto del log
  *
  * @return array
  */
 public function getLogContext()
 {
     return Log::getContext();
 }