示例#1
0
 public function onCorrectedEvent(CorrectedEvent $event)
 {
     $test = $event->getTest();
     $mail = $this->generateMail($test, "CorrigeatonMailerBundle:Mail:mail-corrected.html.twig", $test->getClassroomsEmails());
     if ($this->mailer->send($mail) == 1) {
         $this->log->addInfo("Mail send : " . $test);
     } else {
         $this->log->addError("Error in send mail : " . $test);
     }
 }
 /**
  * Send one or more flash messages to the GUI (alerted in next page).
  * Each message is also logged as INFO (with username) for future reference.
  *
  * @param array $messages a number of clear text information messages
  */
 public function handleMessages(array $messages)
 {
     /** @var User $user */
     $user = $this->container->get('security.context')->getToken()->getUser();
     $username = $user->getUsername();
     $messageText = '';
     foreach ($messages as $message) {
         $this->logger->addInfo("Flash Message({$username}):" . $message);
         $messageText .= $message . "\n";
     }
     if ($messageText !== '') {
         $this->container->get('session')->getFlashBag()->add('notice', $messageText);
     }
 }
 public function testCountErrorsWithoutDebugHandler()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new TestHandler());
     $logger->addInfo('test');
     $logger->addError('uh-oh');
     $this->assertEquals(0, $logger->countErrors());
 }
示例#4
0
 public function redirect($path, $route, $scheme = null, $logPath = null)
 {
     if ($logPath) {
         $logger = new Logger('redirect');
         $logger->pushHandler(new StreamHandler($logPath, Logger::INFO));
         $logger->addInfo('redirect', ['url' => $this->context->getPathInfo() . '?' . $this->context->getQueryString(), 'location' => $path, 'method' => $this->context->getMethod()]);
     }
     return parent::redirect($path, $route, $scheme);
 }
示例#5
0
 public function testGetLogs()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new DebugHandler());
     $logger->addInfo('test');
     $this->assertCount(1, $logger->getLogs());
     list($record) = $logger->getLogs();
     $this->assertEquals('test', $record['message']);
     $this->assertEquals(Logger::INFO, $record['priority']);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->logger->addInfo('Config info:');
     foreach ($this->configInfo as $name => $value) {
         $this->logger->addInfo($name . ': ' . $value);
     }
     $availablePeriods = [4, 8, 24, 168];
     foreach ($availablePeriods as $period) {
         if ($period === 168) {
             if (date('D') !== 'Tue') {
                 continue;
             }
             if (date('H') < 17) {
                 continue;
             }
         }
         $subscribersIndex = $this->subscribersMiner->mine($period);
         $this->sentNotifications($subscribersIndex->getBySubscriberIndex());
     }
 }
 public function loginUser(Request $request)
 {
     $authenticatedUser = $this->googleAuthenticator->authenticateUser($request);
     try {
         $user = $this->googleAuthorizer->authorizeUser($authenticatedUser);
     } catch (FailureAuthorizedException $e) {
         if (!$this->googleRegisterManager->isUserAllowedToRegisterAutomatically($authenticatedUser)) {
             $this->logger->addAlert("User authorization failed ");
             throw new FailureAuthorizedException("XSolve Google Auth couldn't authorize user. User's domain is not allowed");
         }
         $this->googleRegisterManager->registerUser($authenticatedUser);
         $user = $authenticatedUser;
     } catch (NotAuthorizedException $e) {
         $this->logger->addInfo("User try to sign in");
         throw $e;
     }
     $user = $this->FOSUserLoginService->login($user);
     $this->logger->addInfo(sprintf("User %s singed in", $user->getUsername()));
     return $user;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $case = $input->getArgument('case');
     switch ($case) {
         case 'my':
             $this->subscribersMiner->disableAllMiners();
             $this->subscribersMiner->enableMiner('Soil\\CommentsDigestBundle\\SubscribersMiner\\AnswersMiner');
             $this->subscribersMiner->enableMiner('Soil\\CommentsDigestBundle\\SubscribersMiner\\EntityAuthorsMiner');
             break;
         case 'important':
             $this->subscribersMiner->disableAllMiners();
             $this->subscribersMiner->enableMiner('Soil\\CommentsDigestBundle\\SubscribersMiner\\ImportantForMeEntitiesMiner');
             break;
         case 'all':
         default:
             $case = 'all';
     }
     $this->logger->addInfo('Aggregation case ' . $case);
     $subscribersIndex = $this->subscribersMiner->mine($input->getArgument('period'));
     //        $forUser = $subscribersIndex->getForSubscriber("http://www.talaka.by/user/8785");
     $byUserIndex = $subscribersIndex->getBySubscriberIndex();
     //        $userURI = 'http://www.talaka.by/user/12626';
     //        $userIndex = $byUserIndex[$userURI];
     //        var_dump($userIndex);
     //
     //        $this->notifyService->notify('CommentsDigestNotification', $userURI, [
     //            'groupedComments' => $userIndex
     //        ]);
     //        exit();
     foreach ($byUserIndex as $userURI => $groupedComments) {
         try {
             $this->notifyService->notify('CommentsDigestNotification', $userURI, ['groupedComments' => $groupedComments]);
             sleep(1);
         } catch (\Exception $e) {
             echo 'Problem with notification for ' . $userURI;
             var_dump((string) $e);
         }
     }
     //        $subscribersList = $this->subscribersReducer->reduce($subscribersList);
 }
示例#9
0
 /**
  * Comprueba la existencia del fichero de configuración, en caso de no existir intenta crearlo.
  *
  * @return bool
  */
 private function checkConfigFile()
 {
     if (!file_exists($this->aclConfigFile)) {
         $this->logger->addInfo(sprintf('No se encuentra creado el archivo %s.', $this->aclConfigFile));
         if ($file = fopen($this->aclConfigFile, 'w')) {
             fclose($file);
         } else {
             $this->logger->addCritical(sprintf('No se puede crear el archivo %s.', $this->aclConfigFile));
             return false;
         }
     }
     return true;
 }
示例#10
0
 /**
  * @param SiteShowEvent $event
  */
 public function onWardenSiteShow(SiteShowEvent $event)
 {
     $site = $event->getSite();
     if (!$this->isDrupalSite($site)) {
         return;
     }
     $this->logger->addInfo('This is the start of a Drupal show site event: ' . $site->getUrl());
     if (!$site->compareCoreVersion() && $site->getIsSecurityCoreVersion()) {
         $event->addTemplate('DeesonWardenBundle:Drupal:securityUpdateRequired.html.twig');
         $event->addParam('latestCoreVersion', $site->getLatestCoreVersion());
     }
     $event->addTemplate('DeesonWardenBundle:Drupal:siteDetails.html.twig');
     $event->addParam('coreVersion', $site->getCoreVersion());
     $event->addTemplate('DeesonWardenBundle:Drupal:moduleUpdates.html.twig');
     $event->addParam('modulesRequiringUpdates', $site->getModulesRequiringUpdates());
     $event->addTemplate('DeesonWardenBundle:Drupal:modules.html.twig');
     $event->addParam('modules', $site->getModules());
     $this->logger->addInfo('This is the end of a Drupal show site event: ' . $site->getUrl());
 }
示例#11
0
 /**
  * @param string $text
  */
 private function writeLn($text)
 {
     $this->output->writeln($text);
     $this->logger->addInfo($text);
 }
示例#12
0
 public function releaseLock($lock)
 {
     $connection = $this->registry->getConnection();
     $connection->executeQuery("SELECT RELEASE_LOCK(':lock')", array('lock' => $lock));
     $this->logger->addInfo(sprintf('released named lock "%s"', $lock));
 }
示例#13
0
 public function testGetLogsWithDebugProcessor2()
 {
     $handler = new TestHandler();
     $logger = new Logger('test', array($handler));
     $logger->pushProcessor(new DebugProcessor());
     $logger->addInfo('test');
     $this->assertCount(1, $logger->getLogs());
     list($record) = $logger->getLogs();
     $this->assertEquals('test', $record['message']);
     $this->assertEquals(Logger::INFO, $record['priority']);
 }
 /**
  * @param NodeEvent $event
  */
 public function onCreateDraftVersion(NodeEvent $event)
 {
     $this->logger->addInfo(sprintf('%s just created a draft version %d for node %d in language %s', $this->getUser()->getUsername(), $event->getNodeVersion()->getId(), $event->getNode()->getId(), $event->getNodeTranslation()->getLang()));
 }
示例#15
0
 private function delToLog(Friend $friend)
 {
     $log = new Logger('friendchanel');
     $log->pushHandler(new StreamHandler($this->path_file_log, Logger::INFO));
     $log->addInfo('Del Old Friend:' . $this->getInfoFriend($friend));
 }