Example #1
0
 public function __destruct()
 {
     if ($this->_logger && $this->_profiler) {
         $this->_logger->log(sprintf('Total SQL execution time (%d queries): %.4f sec.', $this->_profiler->getNumberTotalStatements(), round($this->_profiler->getTotalElapsedSeconds(), 4)), $this->_priority);
         $this->_logger->commit();
     }
 }
Example #2
0
 public function __destruct()
 {
     if (!is_array($this->_data)) {
         $this->_data = [];
     }
     if (!empty($this->_filterFields) && is_array($this->_filterFields)) {
         $this->_data = array_intersect_key($this->_data, array_flip($this->_filterFields));
     }
     ksort($this->_data);
     $now = new \DateTime();
     $this->_data = array_merge(['_id' => $this->getLogId() ?: uniqid('', true), '_timestamp' => $now->format('c'), '_date' => $now->format('Y-m-d H:i:s')], $this->_data);
     $this->_adapter->log($this->_data, $this->_adapter->getLogLevel());
 }
Example #3
0
 /**
  * Indexes all posts in the forum in ES
  */
 public function indexAll()
 {
     $deleteParams = ['index' => $this->config->get('index', 'phosphorum')];
     try {
         $this->client->indices()->delete($deleteParams);
     } catch (Missing404Exception $e) {
         $this->logger->info('The index does not exist yet. Skip deleting...');
     } catch (\Exception $e) {
         $this->logger->error("Indexer: {$e->getMessage()}. {$e->getFile()}:{$e->getLine()}");
     }
     foreach (Posts::find('deleted != ' . Posts::IS_DELETED) as $post) {
         $this->doIndex($post);
     }
 }
 /**
  * Logs error messages.
  *
  * Events:
  * * breadcrumbs:beforeLogging
  * * breadcrumbs:afterLogging
  *
  * @param \Exception $e
  */
 protected function log(\Exception $e)
 {
     $eventsManager = $this->getEventsManager();
     if ($eventsManager) {
         $eventsManager->fire('breadcrumbs:beforeLogging', $this, [$e]);
     }
     if ($this->logger) {
         $this->logger->error($e->getMessage());
     } else {
         error_log($e->getMessage());
     }
     if ($eventsManager) {
         $eventsManager->fire('breadcrumbs:afterLogging', $this, [$e]);
     }
 }
 /**
  * Execute command in our command executor
  * @param string external command
  *
  */
 private function executeShell($command, &$stdout = null, &$stderr = null)
 {
     $this->logger->info("Execute command: `{$command}`");
     $proc = proc_open($command, [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
     // Find stdout (standar output) from its command
     $stdout = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     // Find stderr (standar error output) from its command
     $stderr = stream_get_contents($pipes[2]);
     fclose($pipes[2]);
     $exitCode = proc_close($proc);
     // Write stdout/stderr into cron service log file
     $this->logger->info("Stdout `{$command}`: {$stdout}");
     $this->logger->error("Stderr `{$command}`: {$stderr}");
     $this->logger->info("Exitcode {$exitCode}");
     return $exitCode;
 }
Example #6
0
 /**
  * Report the uncaught exception (default implementation).
  *
  * @param  Phalcon\Logger\AdapterInterface $logger
  * @param  \Exception $exception
  * @return void
  */
 public function report(Logger $logger, Exception $exception)
 {
     $logger->error($exception->getMessage() . ': ' . $exception->getTraceAsString());
 }