info() публичный Метод

Log message at the INFO level
public info ( string $message ) : boolean
$message string The message to log
Результат boolean
Пример #1
0
 /**
  * Creates a table {prefix}{$namespace}_lock that is used as a mutex.
  *
  * @param string $namespace Allows having separate locks for separate processes
  * @return bool
  */
 public function lock($namespace)
 {
     $this->assertNamespace($namespace);
     if (!$this->isLocked($namespace)) {
         // Lock it
         $this->db->insertData("CREATE TABLE {$this->db->getTablePrefix()}{$namespace}_lock (id INT)");
         $this->logger->info("Locked mutex for {$namespace}");
         return true;
     }
     $this->logger->warn("Cannot lock mutex for {$namespace}: already locked.");
     return false;
 }
Пример #2
0
 /**
  * Invalidate the query cache
  *
  * @return void
  */
 protected function invalidateQueryCache()
 {
     if ($this->query_cache) {
         $this->query_cache->clear();
         if ($this->logger) {
             $this->logger->info("Query cache invalidated");
         }
     }
 }
Пример #3
0
 /**
  * Creates new ElggUpgrade instance from plugin's static config
  *
  * @param \ElggPlugin $plugin Plugin
  * @return \ElggUpgrade[]
  */
 public function getUpgrades(\ElggPlugin $plugin)
 {
     $upgrades = [];
     $batches = $plugin->getStaticConfig('upgrades');
     if (empty($batches)) {
         // No upgrades available for this plugin
         return $upgrades;
     }
     $plugin_id = $plugin->getID();
     foreach ($batches as $class) {
         $batch = $this->getBatch($class);
         if (!$batch) {
             continue;
         }
         $version = $batch::VERSION;
         $upgrade_id = "{$plugin_id}:{$version}";
         // Database holds the information of which upgrades have been processed
         if ($this->upgradeExists($upgrade_id)) {
             $this->logger->info("Upgrade {$upgrade_id} has already been processed");
             continue;
         }
         // Create a new ElggUpgrade to represent the upgrade in the database
         $object = new ElggUpgrade();
         $object->setId($upgrade_id);
         $object->setClass($class);
         $object->title = "{$plugin_id}:upgrade:{$version}:title";
         $object->description = "{$plugin_id}:upgrade:{$version}:description";
         $object->offset = 0;
         try {
             $object->save();
             $upgrades[] = $object;
         } catch (\UnexpectedValueException $ex) {
             $this->logger->error($ex->getMessage());
         }
     }
     return $upgrades;
 }
Пример #4
0
 /**
  * Send a notification to a subscriber
  *
  * @param NotificationEvent $event  The notification event
  * @param int               $guid   The guid of the subscriber
  * @param string            $method The notification method
  * @param array             $params Default notification params
  * @return bool
  * @access private
  */
 protected function sendNotification(NotificationEvent $event, $guid, $method, array $params = [])
 {
     $actor = $event->getActor();
     $object = $event->getObject();
     if ($event instanceof InstantNotificationEvent) {
         $recipient = $this->entities->get($guid);
         /* @var \ElggEntity $recipient */
         $subject = elgg_extract('subject', $params, '');
         $body = elgg_extract('body', $params, '');
         $summary = elgg_extract('summary', $params, '');
     } else {
         $recipient = $this->entities->get($guid, 'user');
         /* @var \ElggUser $recipient */
         if (!$recipient || $recipient->isBanned()) {
             return false;
         }
         if ($recipient->getGUID() == $event->getActorGUID()) {
             // Content creators should not be receiving subscription
             // notifications about their own content
             return false;
         }
         if (!$actor || !$object) {
             return false;
         }
         if ($object instanceof ElggEntity && !has_access_to_entity($object, $recipient)) {
             // Recipient does not have access to the notification object
             // The access level may have changed since the event was enqueued
             return false;
         }
         $subject = $this->getNotificationSubject($event, $recipient);
         $body = $this->getNotificationBody($event, $recipient);
         $summary = '';
         $params['origin'] = Notification::ORIGIN_SUBSCRIPTIONS;
     }
     $language = $recipient->language;
     $params['event'] = $event;
     $params['method'] = $method;
     $params['sender'] = $actor;
     $params['recipient'] = $recipient;
     $params['language'] = $language;
     $params['object'] = $object;
     $params['action'] = $event->getAction();
     $notification = new Notification($actor, $recipient, $language, $subject, $body, $summary, $params);
     $notification = $this->hooks->trigger('prepare', 'notification', $params, $notification);
     if (!$notification instanceof Notification) {
         throw new RuntimeException("'prepare','notification' hook must return an instance of " . Notification::class);
     }
     $type = 'notification:' . $event->getDescription();
     if ($this->hooks->hasHandler('prepare', $type)) {
         $notification = $this->hooks->trigger('prepare', $type, $params, $notification);
         if (!$notification instanceof Notification) {
             throw new RuntimeException("'prepare','{$type}' hook must return an instance of " . Notification::class);
         }
     } else {
         // pre Elgg 1.9 notification message generation
         $notification = $this->getDeprecatedNotificationBody($notification, $event, $method);
     }
     $notification = $this->hooks->trigger('format', "notification:{$method}", [], $notification);
     if (!$notification instanceof Notification) {
         throw new RuntimeException("'format','notification:{$method}' hook must return an instance of " . Notification::class);
     }
     if ($this->hooks->hasHandler('send', "notification:{$method}")) {
         // return true to indicate the notification has been sent
         $params = array('notification' => $notification, 'event' => $event);
         $result = $this->hooks->trigger('send', "notification:{$method}", $params, false);
         if ($this->logger->getLevel() == Logger::INFO) {
             $logger_data = print_r((array) $notification->toObject(), true);
             if ($result) {
                 $this->logger->info("Notification sent: " . $logger_data);
             } else {
                 $this->logger->info("Notification was not sent: " . $logger_data);
             }
         }
         return $result;
     } else {
         // pre Elgg 1.9 notification handler
         $userGuid = $notification->getRecipientGUID();
         $senderGuid = $notification->getSenderGUID();
         $subject = $notification->subject;
         $body = $notification->body;
         $params = $notification->params;
         return (bool) _elgg_notify_user($userGuid, $senderGuid, $subject, $body, $params, array($method));
     }
 }