Exemplo n.º 1
0
 /**
  * Simple reporter log and display information about the queue.
  *
  * @param int $worker
  *   Worker number.
  * @param object $item
  *   The $item which was stored in the cron queue.
  */
 protected function reportWork($worker, $item)
 {
     if ($this->state->get('cron_example_show_status_message')) {
         drupal_set_message($this->t('Queue @worker worker processed item with sequence @sequence created at @time', ['@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created)]));
     }
     $this->logger->get('cron_example')->info('Queue @worker worker processed item with sequence @sequence created at @time', ['@worker' => $worker, '@sequence' => $item->sequence, '@time' => date_iso8601($item->created)]);
 }
Exemplo n.º 2
0
 /**
  * Returns a channel logger object.
  *
  * @param string $channel
  *   The name of the channel. Can be any string, but the general practice is
  *   to use the name of the subsystem calling this.
  *
  * @return \Psr\Log\LoggerInterface
  *   The logger for this channel.
  */
 protected function getLogger($channel)
 {
     if (!$this->loggerFactory) {
         $this->loggerFactory = $this->container()->get('logger.factory');
     }
     return $this->loggerFactory->get($channel);
 }