Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function log($level, $message, array $context = array())
 {
     $classes = [RfcLogLevel::DEBUG => 'dblog-debug', RfcLogLevel::INFO => 'dblog-info', RfcLogLevel::NOTICE => 'dblog-notice', RfcLogLevel::WARNING => 'dblog-warning', RfcLogLevel::ERROR => 'dblog-error', RfcLogLevel::CRITICAL => 'dblog-critical', RfcLogLevel::ALERT => 'dblog-alert', RfcLogLevel::EMERGENCY => 'dblog-emerg'];
     // Processing and rendering follow the logic in DbLog::log and
     // DbLogController:overview.
     $parser = $this->container->get('logger.log_message_parser');
     $date_formatter = $this->container->get('date.formatter');
     $entity_manager = $this->container->get('entity.manager');
     $user_storage = $entity_manager->getStorage('user');
     $variables = $parser->parseMessagePlaceholders($message, $context);
     $message = $this->t((string) $message, $variables);
     $message = strip_tags($message);
     $username_element = ['#theme' => 'username', '#account' => $user_storage->load($context['uid'])];
     $row = ['data' => [['class' => ['icon']], $this->t($context['channel']), $date_formatter->format($context['timestamp'], 'short'), $message, ['data' => $username_element], $context['link']], 'class' => [Html::getClass('dblog-' . $context['channel']), $classes[$level]]];
     // Send ajax command to the fronted to insert the new row into the table
     // on the watchdog page.
     $insert_command = new BeforeCommand('#admin-dblog tr:eq(1)', $this->renderRow($row));
     $commands[] = $insert_command->render();
     $nodejs_message = (object) ['channel' => 'watchdog_dblog', 'commands' => $commands, 'callback' => 'nodejsWatchdog'];
     nodejs_send_content_channel_message($nodejs_message);
 }
Exemplo n.º 2
0
 function sendMessage($action)
 {
     if (module_exists('nodejs')) {
         if (!isset($this->progress_object)) {
             if ($progress = progress_get_progress($this->handle)) {
                 $this->progress_object = $progress;
                 $this->progress = $progress->progress;
                 $this->progress_message = $progress->message;
             } else {
                 $this->progress = 0;
                 $this->progress_message = '';
             }
         }
         $object = clone $this;
         $message = (object) array('channel' => 'background_process', 'data' => (object) array('action' => $action, 'background_process' => $object, 'timestamp' => microtime(TRUE)), 'callback' => 'nodejsBackgroundProcess');
         drupal_alter('background_process_message', $message);
         nodejs_send_content_channel_message($message);
     }
 }