示例#1
0
 public function update(Worker $worker)
 {
     /** @var EntityManager $em */
     $em = $this->doctrine->getManager();
     $exception = null;
     $i = 0;
     while ($i < 5) {
         try {
             $worker = $this->getWorker(['queue' => $worker->getQueue(), 'instance' => $worker->getInstance(), 'host' => $worker->getHost()]);
             $em->persist($worker);
             $em->flush();
             return;
         } catch (\Exception $e) {
             // the connection might have "gone away"
             $this->logger->warning("Error while updating worker entity", ['message' => $e->getMessage()]);
             $exception = $e;
             $this->doctrine->resetManager();
             $em = $this->doctrine->getManager();
             $em->getConnection()->close();
             $em->getConnection()->connect();
         }
         $i++;
     }
     throw new ApplicationException("Unable to update worker entity", $exception);
 }
 private function validateHeader($data, $name)
 {
     if (!$data[0] instanceof \stdClass || !is_array($data[1])) {
         $mes = "Incorrect input param type for {$name}";
         if (isset($this->logger)) {
             $this->logger->warning('ACCESS', ['Cause' => $mes]);
         }
         throw new \Exception($mes);
     }
 }
 public function testLogsFileAndLineWhenUsingIntrospectionProcessor()
 {
     $this->logger->pushProcessor(new IntrospectionProcessor());
     $this->logger->warning('a warning');
     $line = __LINE__;
     $log = $this->pdo->query('SELECT * FROM logs')->fetch();
     $this->assertTrue(isset($log['file']));
     $this->assertTrue(isset($log['line']));
     $this->assertEquals($log['message'], 'a warning');
     $this->assertEquals($log['file'], __FILE__);
     $this->assertEquals($log['line'], $line);
 }
 /**
  * Fetches the data for the given IP address
  *
  * @return $this
  */
 public function getData()
 {
     $url = $this->getUrl();
     try {
         $response = $this->connector->{$this->method}($url);
         $this->parseData($response->body);
     } catch (\Exception $exception) {
         if ($this->logger) {
             $this->logger->warning('IP LOOKUP: ' . $exception->getMessage());
         }
     }
 }
示例#5
0
 protected function stopDaemon()
 {
     if (!file_exists(PHPCI_DIR . '/daemon/daemon.pid')) {
         echo "Not started\n";
         $this->logger->warning("Can't stop daemon as not started");
         return "notstarted";
     }
     $cmd = "kill \$(cat %s/daemon/daemon.pid)";
     $command = sprintf($cmd, PHPCI_DIR);
     exec($command);
     $this->logger->info("Daemon stopped");
     unlink(PHPCI_DIR . '/daemon/daemon.pid');
 }
示例#6
0
 private function weight($imageRegion)
 {
     // Outros efectos para mellorar
     //$imageRegion->negateImage(true);
     //$imageRegion->fxImage('intensity');
     //$imageRegion->contrastImage(1);
     $imageRegion->whiteThresholdImage('#EEE');
     $imageRegion->blackThresholdImage('#EEE');
     /*$basename = $this->basedir . '/%02d.png';
       $imageRegion->writeImage( sprintf($basename, $this->i++) );*/
     // Contar pixels
     $it = new \ImagickPixelIterator($imageRegion);
     //$whitePixel = new \ImagickPixel('#000');
     $whitePixel = new \ImagickPixel('#FFF');
     $totalPixels = 0;
     $dirtyPixels = 0;
     foreach ($it as $pixels) {
         foreach ($pixels as $column => $pixel) {
             if (!$pixel->isSimilar($whitePixel, 0.1)) {
                 $dirtyPixels++;
             }
             $totalPixels++;
         }
         $it->syncIterator();
     }
     $percent = $dirtyPixels * 100 / $totalPixels;
     //dump($percent);
     $this->logger->warning('%: ' . $percent);
     return $percent;
 }
示例#7
0
 /**
  * @param Group $group
  * @param int   $offset
  */
 private function syncGroupUsers(Group $group, $offset = 0)
 {
     $this->logger->info(' - Processing users for Group `' . $group->getName() . '` ' . $offset . ' to ' . ($offset + self::BATCH_SIZE) . '...');
     $ldapUsers = $this->ldap->findGroupUsers($group->getReference(), $offset, self::BATCH_SIZE);
     $grouphubUsers = $this->api->findGroupUsers($group, $offset, self::BATCH_SIZE);
     // Nothing to sync, or done syncing
     if (count($ldapUsers) === 0 && count($grouphubUsers) === 0) {
         $this->logger->info(' - Done syncing Group users!');
         return;
     }
     $index = $grouphubUsers->synchronize($ldapUsers, true);
     $this->logger->info(' -- Going to add ' . count($grouphubUsers->getAddedElements()) . ' users for Group to Grouphub...');
     foreach ($grouphubUsers->getAddedElements() as $element) {
         /** @var User $element */
         $user = $this->api->findUserByReference($element->getReference());
         if (!$user) {
             $this->logger->warning(' -- Skipping user with ref ' . $element->getReference() . ' because it cannot be found in the API?!?');
             continue;
         }
         try {
             $this->api->addGroupUser($group->getId(), $user->getId());
         } catch (\Exception $e) {
             $this->logger->warning(' -- Failed adding user with ref ' . $element->getReference() . ' message: ' . $e->getMessage());
         }
     }
     $this->logger->info(' -- Going to remove ' . count($grouphubUsers->getRemovedElements()) . ' users for Group from Grouphub...');
     foreach ($grouphubUsers->getRemovedElements() as $element) {
         /** @var User $element */
         $this->api->removeGroupUser($group->getId(), $element->getId());
     }
     $this->syncGroupUsers($group, $offset + $index + 1);
 }
示例#8
0
 protected function stopDaemon()
 {
     $pid = $this->getRunningPid();
     if (!$pid) {
         $this->logger->notice("Cannot stop the daemon as it is not started");
         return "notstarted";
     }
     $this->logger->info("Trying to terminate the daemon", array('pid' => $pid));
     $this->processControl->kill($pid);
     for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
         sleep(1);
     }
     if ($pid) {
         $this->logger->warning("The daemon is resiting, trying to kill it", array('pid' => $pid));
         $this->processControl->kill($pid, true);
         for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
             sleep(1);
         }
     }
     if (!$pid) {
         $this->logger->notice("Daemon stopped");
         return "stopped";
     }
     $this->logger->error("Could not stop the daemon");
 }
示例#9
0
 protected function createLogger($path, $level = Logger::WARNING)
 {
     $logger = new Logger('app');
     $logger->pushProcessor(new PsrLogMessageProcessor());
     if (is_writable($path) || is_writable(dirname($path))) {
         $logger->pushHandler(new StreamHandler($path, $level));
     } else {
         if ($this->app->isDebug()) {
             throw new DCException("Log path '{$path}' is not writable. Make sure your logger.path of config.");
         }
         $logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level));
         $logger->warning("Log path '{$path}' is not writable. Make sure your logger.path of config.");
         $logger->warning("error_log() is used for application logger instead at this time.");
     }
     return $logger;
 }
 protected function extract(Account $account, Profile $profile, $tableName, $dateFrom, $dateTo)
 {
     $config = $account->getConfiguration();
     $cfg = $config[$tableName];
     $filters = isset($cfg['filters'][0]) ? $cfg['filters'][0] : null;
     $segment = isset($cfg['segment']) ? $cfg['segment'] : null;
     $resultSet = $this->gaApi->getData($profile->getGoogleId(), $cfg['dimensions'], $cfg['metrics'], $filters, $segment, $dateFrom, $dateTo);
     $this->logger->info("Extracting ...", ['dimensions' => $cfg['dimensions'], 'metrics' => $cfg['metrics'], 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, 'results' => count($resultSet)]);
     if (empty($resultSet)) {
         $this->logger->warning("Query returned empty result", ['account' => $account->getAccountName(), 'profile' => $profile->getName(), 'outputTable' => $tableName]);
         return;
     }
     $csv = $this->getOutputCsv($tableName, $profile);
     $this->getDataManager()->saveToCsv($resultSet, $profile, $csv);
     // Paging
     $params = $this->gaApi->getDataParameters();
     if ($params['totalResults'] > $params['itemsPerPage']) {
         $pages = ceil($params['totalResults'] / $params['itemsPerPage']);
         for ($i = 1; $i < $pages; $i++) {
             $start = $i * $params['itemsPerPage'] + 1;
             $resultSet = $this->gaApi->getData($profile->getGoogleId(), $cfg['dimensions'], $cfg['metrics'], $filters, $segment, $dateFrom, $dateTo, 'ga:date', $start, $params['itemsPerPage']);
             $this->getDataManager()->saveToCsv($resultSet, $profile, $csv, true);
         }
     }
     $this->getDataManager()->uploadCsv($csv->getPathname(), $this->getOutputTable($account, $tableName), true);
 }
 public static function warning($message, $context = array())
 {
     $logger = new Logger('api_log');
     $file = static::prepare('warning');
     $logger->pushHandler(new StreamHandler($file, Logger::INFO));
     $logger->warning($message, $context);
 }
示例#12
0
文件: Logger.php 项目: acgrid/adbot
 public function warning($message, array $args = [], array $context = [])
 {
     if (count($args)) {
         $message = vsprintf($message, $args);
     }
     return parent::warning($message, $context);
 }
示例#13
0
 /**
  * @covers Monolog\Logger::addRecord
  */
 public function testLogNotHandled()
 {
     $logger = new Logger(__METHOD__);
     $handler = $this->getMock('Monolog\\Handler\\NullHandler', array('handle'), array(Logger::ERROR));
     $handler->expects($this->never())->method('handle');
     $logger->pushHandler($handler);
     $this->assertFalse($logger->warning('test'));
 }
 public function initManager(\GearmanJob $job)
 {
     $this->job = $job;
     $this->gearmanDto = unserialize($job->workload());
     $this->processManager = ProcessManagerFactory::getProcessManager($this->gearmanDto->getManagerType());
     $this->processManager->setJob($job);
     $this->processManager->setGearmanDto($this->gearmanDto);
     try {
         $this->processManager->manage();
     } catch (\Exception $e) {
         $errorMessage = "Gearman process manager die with exception: " . $e->getMessage() . "| gearmanDto: " . serialize($this->gearmanDto);
         $this->logger->warning($errorMessage);
         $this->processManager->getExecutionDto()->setErrorMessage($errorMessage);
         die;
     }
     return null;
 }
示例#15
0
 protected function makeAttentionLog($inspectionMessage)
 {
     if (!$this->allTasksComplete) {
         $this->logger->error("Inspection message: " . $inspectionMessage);
     }
     $this->logger->warning("Executed with Error: " . serialize($this->executedWithError));
     return null;
 }
示例#16
0
 public static function sayHi()
 {
     $log = new newClass('name');
     $log->pushHandler(new StreamHandler(__DIR__ . '/new.log', newClass::WARNING));
     // add records to the log
     $log->warning('Foo');
     $log->error('Bar');
 }
示例#17
0
 /**
  *
  */
 public function testPushErrors()
 {
     $redis = \Mockery::mock('Predis\\Client')->shouldReceive('publish')->times(8)->with('log', \Mockery::any())->mock();
     $monolog = new Logger('test');
     $monolog->pushHandler(new PublishHandler(new RedisPublisher($redis)));
     $monolog->debug('the message was: {message}', ['DEBUG!']);
     $monolog->info('the message was: {message}', ['INFO!']);
     $monolog->notice('the message was: {message}', ['NOTICE!']);
     $monolog->warning('the message was: {message}', ['WARNING!']);
     $monolog->error('the message was: {message}', ['ERROR!']);
     $monolog->critical('the message was: {message}', ['CRITICAL!']);
     $monolog->alert('the message was: {message}', ['ALERT!']);
     $monolog->emergency('the message was: {message}', ['EMERGENCY!']);
 }
示例#18
0
 /**
  * Fire an event
  *
  * @param   string  $event      Event name
  * @param   string  $type       the type of event
  * @param   Object  $data       Data to provide to callback
  */
 public final function fire($event, $type, $data)
 {
     $this->logger->info('Firing event', array('EVENT' => $event));
     $value = $data;
     if (isset($this->hooks[$event])) {
         foreach ($this->hooks[$event] as $callback) {
             $return_value = null;
             if (is_array($callback)) {
                 if (is_callable(array($callback[0], $callback[1]))) {
                     try {
                         $return_value = call_user_func(array($callback[0], $callback[1]), $value);
                     } catch (Exception $e) {
                         $this->logger->error('Hook error', array('EVENT' => $event, 'CALLBACK' => $callback[0], 'METHOD' => $callback[1], 'CODE' => $e->getCode(), 'MESSAGE' => $e->getMessage()));
                         continue;
                     }
                 } else {
                     $this->logger->warning('Skipping not-callable hook', array('EVENT' => $event, 'CALLBACK' => $callback[0], 'METHOD' => $callback[1]));
                     continue;
                 }
             } else {
                 if (is_callable($callback)) {
                     try {
                         $return_value = call_user_func($callback, $value);
                     } catch (Exception $e) {
                         $this->logger->error('Hook error', array('EVENT' => $event, 'CALLBACK' => $callback, 'CODE' => $e->getCode(), 'MESSAGE' => $e->getMessage()));
                         continue;
                     }
                 } else {
                     $this->logger->warning('Skipping not-callable hook', array('EVENT' => $event, 'CALLBACK' => $callback));
                     continue;
                 }
             }
             switch ($type) {
                 case 'TASKSTABLE':
                     $value = $return_value instanceof \Comodojo\Extender\TasksTable ? $return_value : $value;
                     break;
                 case 'SCHEDULE':
                     $value = $return_value instanceof \Comodojo\Extender\Scheduler\Schedule ? $return_value : $value;
                     break;
                 case 'VOID':
                 default:
                     // $value = $value;
                     break;
             }
         }
         return $value;
     }
     return $data;
 }
 /**
  * Fetch one deposit from LOCKSSOMatic.
  *
  * @param Deposit $deposit
  * @param string  $href
  */
 public function fetch(Deposit $deposit, $href)
 {
     $client = $this->getHttpClient();
     $filepath = $this->filePaths->getRestoreDir($deposit->getJournal()) . '/' . basename($href);
     $this->logger->notice("Saving {$deposit->getJournal()->getTitle()} vol. {$deposit->getVolume()} no. {$deposit->getIssue()} to {$filepath}");
     try {
         $client->get($href, array('allow_redirects' => false, 'decode_content' => false, 'save_to' => $filepath));
         $hash = strtoupper(hash_file($deposit->getPackageChecksumType(), $filepath));
         if ($hash !== $deposit->getPackageChecksumValue()) {
             $this->logger->warning("Package checksum failed. Expected {$deposit->getPackageChecksumValue()} but got {$hash}");
         }
     } catch (Exception $ex) {
         $this->logger->error($ex->getMessage());
     }
 }
示例#20
0
 /**
  * Catch results from completed jobs
  * 
  */
 private function catcher()
 {
     $exec_time = microtime(true);
     while (!empty($this->running_processes)) {
         foreach ($this->running_processes as $pid => $job) {
             //$job[0] is name
             //$job[1] is uid
             //$job[2] is start timestamp
             //$job[3] is job id
             if (!self::isRunning($pid)) {
                 list($reader, $writer) = $this->ipc_array[$job[1]];
                 socket_close($writer);
                 $parent_result = socket_read($reader, $this->max_result_bytes_in_multithread, PHP_BINARY_READ);
                 if ($parent_result === false) {
                     $this->logger->error("socket_read() failed. Reason: " . socket_strerror(socket_last_error($reader)));
                     array_push($this->completed_processes, array(null, $job[0], false, $job[2], null, "socket_read() failed. Reason: " . socket_strerror(socket_last_error($reader)), $job[3], null));
                     $status = 'ERROR';
                 } else {
                     $result = unserialize(rtrim($parent_result));
                     socket_close($reader);
                     array_push($this->completed_processes, array($pid, $job[0], $result["success"], $job[2], $result["timestamp"], $result["result"], $job[3], $result["worklogid"]));
                     $status = $result["success"] ? 'success' : 'failure';
                 }
                 $this->logger->notice("Job " . $job[0] . "(" . $job[3] . ") ends with " . $status);
                 unset($this->running_processes[$pid]);
                 $this->logger->info("Removed pid " . $pid . " from the running queue, job terminated with " . $status);
             } else {
                 $current_time = microtime(true);
                 if ($current_time > $exec_time + $this->max_childs_runtime) {
                     $this->logger->warning("Killing pid " . $pid . " due to maximum exec time reached (>" . $this->max_childs_runtime . ")", array("START_TIME" => $exec_time, "CURRENT_TIME" => $current_time, "MAX_RUNTIME" => $this->max_childs_runtime));
                     $kill = self::kill($pid);
                     if ($kill) {
                         $this->logger->warning("Pid " . $pid . " killed");
                     } else {
                         $this->logger->warning("Pid " . $pid . " could not be killed");
                     }
                     list($reader, $writer) = $this->ipc_array[$job[1]];
                     socket_close($writer);
                     socket_close($reader);
                     array_push($this->completed_processes, array($pid, $job[0], false, $job[2], $current_time, "Job " . $job[0] . " killed due to maximum exec time reached (>" . $this->max_childs_runtime . ")", $job[3], null));
                     $this->logger->notice("Job " . $job[0] . "(" . $job[3] . ") ends with error");
                     unset($this->running_processes[$pid]);
                     $this->logger->info("Removed pid " . $pid . " from the running queue, job terminated with error");
                 }
             }
         }
     }
 }
示例#21
0
 /**
  * Logs a user in to QBank.
  * @internal Do NOT save this info in the class anywhere!
  * @param string $username The users username.
  * @param string $password The users password.
  * @param int $languageId The language id to use.
  * @throws ConnectionException Thrown if something went wrong with the connection.
  * @author Björn Hjortsten
  * @return bool True if the login was successfull, false if not.
  */
 public function login($username, $password, $languageId = null)
 {
     $data = array('username' => $username, 'password' => $password);
     if (!empty($languageId)) {
         $data['languageId'] = intval($languageId);
     }
     try {
         $result = $this->call('login', $data);
     } catch (CommunicationException $ce) {
         $this->wrapperLog->warning('Faulty login.', array('username' => $username));
         return false;
     }
     $this->wrapperLog->info('Login.', array('hash' => $result->hash));
     $this->setHash($result->hash);
     return true;
 }
示例#22
0
 protected function writeTable(CsvFile $csv, $outputTable, $incremental, $primaryKey)
 {
     try {
         $tableNameArr = explode('.', $outputTable);
         $bucketId = $tableNameArr[0] . "." . $tableNameArr[1];
         $tableName = $tableNameArr[2];
     } catch (ContextErrorException $e) {
         throw new UserException("Wrong output table name.", $e);
     }
     if (!count($csv->getHeader())) {
         throw new ApplicationException("Trying to upload an empty file");
     }
     try {
         if (!$this->storageApi->bucketExists($bucketId)) {
             $bucketArr = explode('.', $bucketId);
             $this->storageApi->createBucket(str_replace('c-', '', $bucketArr[1]), SapiClient::STAGE_IN, 'DB Extractor data bucket');
         }
         if (!$this->storageApi->tableExists($outputTable)) {
             $this->storageApi->createTableAsync($bucketId, $tableName, $csv, array('primaryKey' => $primaryKey));
         } else {
             // handle unexpected temporary errors like "unable to fork()"
             $success = false;
             $exception = null;
             for ($i = 0; $i < 2 && !$success; $i++) {
                 try {
                     $this->storageApi->writeTableAsync($outputTable, $csv, array('incremental' => $incremental));
                     $success = true;
                 } catch (\Exception $e) {
                     $exception = $e;
                     $this->logger->warning("Error writing to SAPI", ['exception' => $exception]);
                 }
                 sleep(1);
             }
             if (!$success) {
                 throw $exception;
             }
         }
     } catch (ClientException $e) {
         if ($e->getCode() < 500) {
             throw new UserException($e->getMessage(), $e);
         } else {
             throw new ApplicationException($e->getMessage(), $e);
         }
     }
     $this->logger->info("Table " . $tableName . " imported to Storage API");
 }
示例#23
0
 /**
  * Sets the parameters of the XSLT processor.
  *
  * @param TransformationObject $transformation Transformation.
  * @param \XSLTProcessor       $proc           XSLTProcessor.
  *
  * @return void
  */
 public function setProcessorParameters(TransformationObject $transformation, $proc)
 {
     foreach ($this->xsl_variables as $key => $variable) {
         // XSL does not allow both single and double quotes in a string
         if (strpos($variable, '"') !== false && strpos($variable, "'") !== false) {
             $this->logger->warning('XSLT does not allow both double and single quotes in ' . 'a variable; transforming single quotes to a character ' . 'encoded version in variable: ' . $key);
             $variable = str_replace("'", "&#39;", $variable);
         }
         $proc->setParameter('', $key, $variable);
     }
     // add / overwrite the parameters with those defined in the
     // transformation entry
     $parameters = $transformation->getParameters();
     if (isset($parameters['variables'])) {
         /** @var \DOMElement $variable */
         foreach ($parameters['variables'] as $key => $value) {
             $proc->setParameter('', $key, $value);
         }
     }
 }
示例#24
0
 /**
  * @return null
  */
 public function handleInspection()
 {
     if (!empty($this->tasksInspector->getCreatedTasks())) {
         $this->recursionAttempts++;
         $repeatedTasks = "Repeated tasks: " . serialize($this->tasksInspector->getCreatedTasks());
         if ($this->recursionAttempts < ClientConstants::MAX_RECURSION_CALL_TASKS) {
             $this->logger->warning("Client " . $this->moduleName . " start to init tasks repeatedly. | " . $repeatedTasks);
             sleep(ClientConstants::MAX_GET_TASK_ATTEMPTS + $this->additionalSleepTime);
             $this->initTasks($this->tasksInspector->getCreatedTasks());
         } else {
             $attentionMsg = "Client " . $this->moduleName . " exceeded max recursionCallTasks constant (" . ClientConstants::MAX_RECURSION_CALL_TASKS . ") and finished. | " . $repeatedTasks;
             $this->tasksInspector->sendAttentionMail($attentionMsg);
             $this->logger->warning($attentionMsg);
             $this->recursionCallFinished = true;
         }
     } else {
         $this->tasksInspector->sendAttentionMail("All good. Inspection message: " . $this->inspectionDto->getInspectionMessage());
     }
     if ($this->tasksInspector->isMustDie()) {
         die;
     }
     return null;
 }
示例#25
0
 public function createLog()
 {
     $log = new Logger('name');
     $log->pushHandler(new StreamHandler('/var/www/test1.local/logDir/e.log', Logger::WARNING));
     $log->warning('Warning!');
 }
示例#26
0
 /**
  * Exceptional occurrences that are not errors.
  *
  * Example: Use of deprecated APIs, poor use of an API, undesirable things
  * that are not necessarily wrong.
  *
  * @param string $message
  * @param array $context
  * @return null
  */
 public function warning($message, array $context = array())
 {
     $this->logger->warning($message, $context);
 }
示例#27
0
 /**
  * @param string $message
  */
 public function logUntranslated($message)
 {
     if ($this->logger !== NULL) {
         $this->logger->warning("Untranslated message '{$message}'");
     }
 }
 /**
  * Send the newsletter for one recipient
  * @param  integer     $recipientId
  * @param  array       $params          params and contentItems that are the same for all recipients
  * @param  string      $wrapperTemplate
  * @return string|null or the failed email addressess
  */
 public function sendNewsletterFor($recipientId, array $params, $wrapperTemplate)
 {
     $recipient = $this->recipientProvider->getRecipient($recipientId);
     // create new array for each recipient.
     $recipientParams = array_merge($params, $this->getRecipientSpecificNewsletterParams($recipient));
     // get the recipient-specific contentItems of the newsletter
     $recipientContentItems = $this->getRecipientSpecificNewsletterContentItems($recipient);
     // merge the recipient-specific and the general content items. recipient-specific first/at the top!
     $recipientParams[self::CONTENT_ITEMS] = array_merge($recipientContentItems, $params[self::CONTENT_ITEMS]);
     $recipientParams['_locale'] = $recipient->getPreferredLocale();
     if (sizeof($recipientParams[self::CONTENT_ITEMS]) == 0) {
         $this->logger->warning("The newsletter for '" . $recipient->getDisplayName() . " <" . $recipient->getEmail() . ">' has not been sent. It would have been empty.", $params);
         return $recipient->getEmail();
     }
     $subject = $this->getRecipientSpecificNewsletterSubject($params[self::CONTENT_ITEMS], $recipientContentItems, $params, $recipient, $recipient->getPreferredLocale());
     // render and send the email with the right wrapper-template
     $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $recipientParams, $wrapperTemplate . ".txt.twig", $recipient->getPreferredLocale());
     if ($sent) {
         // save that this recipient has recieved the newsletter
         return null;
     } else {
         $this->logger->error("The newsletter for " . $recipient->getDisplayName() . " <" . $recipient->getEmail() . "> could not be sent!", $params);
         return $recipient->getEmail();
     }
 }
示例#29
0
 /**
  * Adds a log record at the WARNING level.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  * @static 
  */
 public static function warning($message, $context = array())
 {
     return \Monolog\Logger::warning($message, $context);
 }
 /**
  * Exceptional occurrences that are not errors.
  *
  * Example: Use of deprecated APIs, poor use of an API, undesirable things
  * that are not necessarily wrong.
  *
  * @param string $message
  * @param array $params
  * @param array $context
  * @return null
  */
 public function warning($message, array $params = array(), array $context = array())
 {
     $logMessage = $this->createMessage($message, $params);
     $this->logger->warning($logMessage, $context);
 }