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

Adds a log record at the WARNING level.
public addWarning ( string $message, array $context = [] ) : boolean
$message string The log message
$context array The log context
Результат boolean Whether the record has been processed
Пример #1
0
 protected function writeEntry($level, $message, $indent, $category = "", $additionalData = [])
 {
     $message = str_pad($category, 16, " ", STR_PAD_RIGHT) . "\t" . str_repeat("  ", $indent) . $message;
     switch ($level) {
         case Log::BULK_DATA_LEVEL:
             $this->logger->addDebug($message, $additionalData);
             break;
         case Log::DEBUG_LEVEL:
             $this->logger->addDebug($message, $additionalData);
             break;
         case Log::ERROR_LEVEL:
             $this->logger->addError($message, $additionalData);
             break;
         case Log::PERFORMANCE_LEVEL:
             $this->logger->addNotice($message, $additionalData);
             break;
         case Log::WARNING_LEVEL:
             $this->logger->addWarning($message, $additionalData);
             break;
         case Log::REPOSITORY_LEVEL:
             $this->logger->addNotice($message, $additionalData);
             break;
         default:
             $this->logger->addNotice($message, $additionalData);
     }
 }
Пример #2
0
 /**
  * @param string $token Access token from the calling client
  *
  * @return string|false The result from the cURL call against the oauth API.
  *
  * @codeCoverageIgnore This function is not tested because we can't test
  *                     curl_* calls in PHPUnit.
  */
 protected function _call($token)
 {
     $ch = curl_init();
     $url = $this->_apiUrl . $token;
     $this->_logger->addDebug('calling GET: ' . $url);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
     $result = curl_exec($ch);
     $responseCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $curlErrno = curl_errno($ch);
     $curlError = curl_error($ch);
     // remove token from url for log output
     $url = substr($url, 0, stripos($url, 'token') + 6);
     if (0 !== $curlErrno) {
         $this->_logger->addError('curl error (' . $curlErrno . '): ' . $curlError . ' url: ' . $url);
     }
     if ($responseCode >= 500) {
         $this->_logger->addError('curl call error: ' . $responseCode . ' url: ' . $url);
     } elseif ($responseCode >= 300) {
         $this->_logger->addWarning('curl call warning: ' . $responseCode . ' url: ' . $url);
     }
     $this->_logger->addDebug('result: (' . $responseCode . ') ' . var_export($result, true));
     curl_close($ch);
     return $result;
 }
 public function log($message, $priority = self::INFO)
 {
     if ($message instanceof \Exception) {
         $message = $message->getMessage();
         $context = [];
     } elseif (is_string($message)) {
         $context = [];
     } else {
         $context = $message;
         unset($context[0]);
         unset($context[1]);
         if (isset($message[1])) {
             $message = preg_replace('#\\s*\\r?\\n\\s*#', ' ', trim($message[1]));
         }
     }
     switch ($priority) {
         case self::DEBUG:
             return $this->monolog->addDebug($message, $context);
         case self::CRITICAL:
             return $this->monolog->addCritical($message, $context);
         case self::ERROR:
             return $this->monolog->addError($message, $context);
         case self::EXCEPTION:
             return $this->monolog->addEmergency($message, $context);
         case self::WARNING:
             return $this->monolog->addWarning($message, $context);
         case 'access':
             return $this->monolog->addNotice($message, $context);
         case 'emergency':
             return $this->monolog->addEmergency($message, $context);
         default:
             return $this->monolog->addInfo($message, $context);
     }
 }
Пример #4
0
 /**
  * Uses the Monolog file Logger to write a log message in a file.
  *
  * @param  string   $message  Message that needs to be output
  * @param  bool  $error    If the log message is considered an error, for logging purposes
  */
 public function write($message, $error = false)
 {
     if (!$error) {
         $this->logger->addWarning($message);
         return;
     }
     $this->logger->addError($message);
 }
Пример #5
0
 /**
  * Add Module
  * @param string $moduleName
  * @param array  $args
  */
 public function addModule($moduleName, $args = [])
 {
     try {
         $module = $this->moduleFactory->build($moduleName, PHP_OS, $args);
         $this->moduleComposite->addComponent($module);
     } catch (ModuleException $e) {
         $this->logger->addWarning($e->getMessage());
     }
 }
Пример #6
0
 /**
  * @param string|null $type
  * @return array
  */
 public function getAll($type = null)
 {
     $type = strtolower($type);
     if (!empty($this->config[$type])) {
         return $this->config[$type];
     }
     $this->logger->addWarning('Config group not found: [' . $type . ']');
     return array();
 }
Пример #7
0
 /**
  * Send the email
  *
  * @return void
  */
 public function send()
 {
     if ($this->enabled) {
         if (!$this->emailer->send()) {
             $this->logger->addWarning($this->emailer->error());
         }
     } else {
         $this->logger->addWarning('Faked sending an email ' . $this->emailer->get('body'));
     }
 }
Пример #8
0
 /**
  * @param array $inputArray
  * @param string[] $columNamesInDatabase
  * @return null|string[]
  */
 public function getSortingParametersFromArray($inputArray, $columNamesInDatabase, $defaultSearch = array())
 {
     if (array_key_exists('iSortingCols', $inputArray)) {
         if ($inputArray['iSortingCols'] > count($columNamesInDatabase)) {
             $this->logger->addWarning("did have enough columNames for " . $inputArray['iSortingCols'] . " sort columns.");
             return null;
         }
         return $this->getSortingParametersFromArrayImpl($inputArray, $columNamesInDatabase, $defaultSearch);
     } else {
         $this->logger->addWarning("did not find iSortingCols in inputArray");
         return null;
     }
 }
Пример #9
0
 /**
  * Log a message
  *
  * @param string $message
  * @param int    $level
  * @param array $context
  * @return void
  */
 public function log($message, $level = Logger::INFO, array $context = [])
 {
     if (!$this->logger) {
         return;
     }
     if (null === $level) {
         $level = Logger::INFO;
     }
     switch ($level) {
         case Logger::DEBUG:
             $this->logger->addDebug($message, $context);
             break;
         case Logger::INFO:
             $this->logger->addInfo($message, $context);
             break;
         case Logger::NOTICE:
             $this->logger->addNotice($message, $context);
             break;
         case Logger::WARNING:
             $this->logger->addWarning($message, $context);
             break;
         case Logger::ERROR:
             $this->logger->addError($message, $context);
             break;
         case Logger::CRITICAL:
             $this->logger->addCritical($message, $context);
             break;
         case Logger::EMERGENCY:
             $this->logger->addEmergency($message, $context);
             break;
         default:
             break;
     }
 }
Пример #10
0
 /**
  * Отправляет сообщение в лог
  *
  * @param string $message сообщение
  * @param int    $level   уровень
  *
  * @return void
  */
 public function log($message, $level = AbstractLogger::NOTICE)
 {
     if ($level < $this->severity) {
         return;
     }
     switch ($level) {
         case AbstractLogger::EMERGENCY:
             $this->impl->addEmergency($message);
             break;
         case AbstractLogger::ALERT:
             $this->impl->addAlert($message);
             break;
         case AbstractLogger::CRITICAL:
             $this->impl->addCritical($message);
             break;
         case AbstractLogger::ERROR:
             $this->impl->addError($message);
             break;
         case AbstractLogger::WARNING:
             $this->impl->addWarning($message);
             break;
         case AbstractLogger::NOTICE:
             $this->impl->addNotice($message);
             break;
         case AbstractLogger::INFO:
             $this->impl->addInfo($message);
             break;
         case AbstractLogger::DEBUG:
             $this->impl->addDebug($message);
             break;
     }
 }
 /**
  * Update an existing user
  *
  * @param int $id
  * @param HttpFoundation\Request $request
  * @return HttpFoundation\JsonResponse|HttpFoundation\Response
  */
 public function putIndex($id, HttpFoundation\Request $request)
 {
     $this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'type' => 'request']);
     //If this request validated then the userId should be in the request.
     $userId = $request->request->get('userId');
     if ($userId === $id) {
         $user = $this->repo->getById($userId);
         $this->log->addDebug(print_r($user, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'type' => 'user']);
         //It's almost impossible for this to happen but it's good defensive coding.
         if (!empty($user)) {
             $user = $this->converter->entityArrayToModel(json_decode($request->getContent(), true), new Models\User());
             $user->id = $userId;
             if (isset($user->password)) {
                 $user->password = password_hash($user->password, PASSWORD_DEFAULT);
             }
             if ($this->repo->save($user)) {
                 $this->log->addInfo('Updated user', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'user' => (array) $user]);
                 return new HttpFoundation\JsonResponse($user, 200);
             }
             //Otherwise we couldn't save the user for some reason
             $this->log->addWarning('Unable to update user', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'request' => $request->getContent(), 'user' => (array) $user]);
             return new HttpFoundation\Response('Bad Request', 400);
         }
     }
     //We didn't find a user to update.
     $this->log->addWarning('No user found', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'id' => $id, 'userId' => $userId]);
     return new HttpFoundation\Response('Not Found', 404);
 }
Пример #12
0
 /**
  * @param array $fromCols
  * @param array $toCols
  * @throws StructureException
  * @throws \Exception
  */
 public function compareColumns($fromCols, $toCols)
 {
     $columnClass = new \ReflectionClass('rombar\\PgExplorerBundle\\Models\\dbElements\\Column');
     if (count($fromCols) == 0 || count($toCols) == 0) {
         throw new \Exception('A table has no columns!');
     }
     $ignoredMethods = ['getTable', 'getRealPosition', 'getOid'];
     list($namesFrom, $namesTo) = $this->compareColumnsNames($fromCols, $toCols);
     foreach ($namesFrom as $fromKey => $fromColName) {
         $fromCol = $fromCols[$fromKey];
         $toCol = $toCols[array_search($fromColName, $namesTo)];
         foreach ($columnClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
             if (preg_match('#^get#', $method->name) && !in_array($method->name, $ignoredMethods)) {
                 $getter = $method->name;
                 if ($fromCol->{$getter}() != $toCol->{$getter}()) {
                     //Special hook for nextval.
                     // With certain search path, the schema can be omitted wich make a false positive.
                     if ($getter == 'getDefault' && preg_match('/^nextval/', $fromCol->{$getter}())) {
                         $diff = str_replace('.', '', Utils::stringDiff($fromCol->{$getter}(), $toCol->{$getter}()));
                         $this->logger->addDebug('diff search_path : ' . $diff);
                         if (in_array($diff, $this->toAnalyzer->getSearchPath()) || in_array($diff, $this->fromAnalyzer->getSearchPath())) {
                             $this->logger->addWarning('Bypass by search_path test for ' . $getter . ' : ' . $fromCol->{$getter}() . ' vs ' . $toCol->{$getter}());
                             continue;
                         }
                     }
                     $this->logger->addWarning('Column ' . $fromColName . '->' . $getter . '() : ' . $fromCol->{$getter}() . ' vs ' . $toCol->{$getter}());
                     var_dump($fromCol);
                     var_dump($toCol);
                     throw new StructureException('Targeted database has a different column ' . $fromCol->getName() . ' in table ' . $fromCol->getSchema() . PgAnalyzer::DB_SEPARATOR . $this->fromAnalyzer->getTable($fromCol->getSchema(), $fromCol->getTable())->getName() . ' check the property ' . substr($getter, 3));
                 }
             }
         }
     }
 }
Пример #13
0
 protected function findTextByKey($steps, $count)
 {
     $node = $this->source;
     foreach (explode('.', $steps) as $step) {
         if (!isset($node[$step])) {
             $this->log->addWarning("Translation for '{$steps}' not found, missing key '{$step}'", [$this->language]);
             return NULL;
         }
         $node = $node[$step];
     }
     if (!is_array($node)) {
         if ($count !== NULL) {
             $this->log->addNotice("Translation for '{$steps}' has no plurals, but count '{$count}' was passed", [$this->language]);
         }
         return $node;
     }
     if ($count === NULL) {
         $this->log->addNotice("Translation for '{$steps}' has plurals, but no count was passed", [$this->language]);
     }
     $keys = $this->countToKey($count);
     foreach ($keys as $key) {
         if (isset($node[$key])) {
             return $node[$key];
         }
     }
     $this->log->addWarning("Translation for '{$steps}' is missing plurals", [$this->language]);
     return NULL;
 }
Пример #14
0
 /**
  * Start the worker.
  */
 public function startWorker()
 {
     $this->pheanstalk->watch($this->queue);
     $this->pheanstalk->ignore('default');
     $buildStore = Factory::getStore('Build');
     while ($this->run) {
         // Get a job from the queue:
         $job = $this->pheanstalk->reserve();
         $this->checkJobLimit();
         // Get the job data and run the job:
         $jobData = json_decode($job->getData(), true);
         if (!$this->verifyJob($job, $jobData)) {
             continue;
         }
         $this->logger->addInfo('Received build #' . $jobData['build_id'] . ' from Beanstalkd');
         // If the job comes with config data, reset our config and database connections
         // and then make sure we kill the worker afterwards:
         if (!empty($jobData['config'])) {
             $this->logger->addDebug('Using job-specific config.');
             $currentConfig = Config::getInstance()->getArray();
             $config = new Config($jobData['config']);
             Database::reset($config);
         }
         try {
             $build = BuildFactory::getBuildById($jobData['build_id']);
         } catch (\Exception $ex) {
             $this->logger->addWarning('Build #' . $jobData['build_id'] . ' does not exist in the database.');
             $this->pheanstalk->delete($job);
         }
         try {
             // Logging relevant to this build should be stored
             // against the build itself.
             $buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
             $this->logger->pushHandler($buildDbLog);
             $builder = new Builder($build, $this->logger);
             $builder->execute();
             // After execution we no longer want to record the information
             // back to this specific build so the handler should be removed.
             $this->logger->popHandler($buildDbLog);
         } catch (\PDOException $ex) {
             // If we've caught a PDO Exception, it is probably not the fault of the build, but of a failed
             // connection or similar. Release the job and kill the worker.
             $this->run = false;
             $this->pheanstalk->release($job);
         } catch (\Exception $ex) {
             $build->setStatus(Build::STATUS_FAILED);
             $build->setFinished(new \DateTime());
             $build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
             $buildStore->save($build);
             $build->sendStatusPostback();
         }
         // Reset the config back to how it was prior to running this job:
         if (!empty($currentConfig)) {
             $config = new Config($currentConfig);
             Database::reset($config);
         }
         // Delete the job when we're done:
         $this->pheanstalk->delete($job);
     }
 }
Пример #15
0
 public function index()
 {
     $this->load->view('welcome_message');
     $log = new Logger('test001');
     $log->pushHandler(new StreamHandler('/tmp/my.log', Logger::WARNING));
     $log->addWarning('Foo');
     $log->addError('Bar');
 }
Пример #16
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->addWarning('test'));
 }
Пример #17
0
 public function log()
 {
     // create a log channel
     $log = new Logger('name');
     $log->pushHandler(new StreamHandler(BASE_PATH . '/storage/log/demo.log', Logger::WARNING));
     // add records to the log
     $log->addWarning('Foo');
     $log->addError('Bar');
 }
Пример #18
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $log = new Logger('captcha');
     $log->pushHandler(new StreamHandler('app/logs/captcha.log', Logger::WARNING));
     $log->addWarning('Start scrap');
     for ($i = 0; $i < 1000; $i++) {
         $this->parseCaptcha();
     }
 }
Пример #19
0
 public function indexAction()
 {
     // create a log channel
     $log = new Logger('name');
     $log->pushHandler(new StreamHandler(LOG_PATH, Logger::WARNING));
     // add records to the log
     $log->addWarning('Foo', array('username' => 'Seldaek'));
     $log->addError('Bar');
     $log->pushProcessor(function ($record) {
         $record['extra']['dummy'] = 'Hello world!';
         return $record;
     });
     exit;
     $em = $this->getEntityManager();
     //         $user = new \Application\Entity\AssUser();
     //         $objectManager->persist($user);
     // //         $objectManager->flush();
     $user = $em->find("Application\\Entity\\AssUser", 2);
     $myFirstComment = new \Application\Entity\AssComment();
     $user->setFirstComment($myFirstComment);
     $em->persist($myFirstComment);
     $em->flush();
     //         $user = new \Application\Entity\User();
     //         $user->setName('engineer');
     //         $objectManager->persist($user);
     //         $objectManager->flush();
     //         $productIds = array(1,2,3);
     //         $reporter = $objectManager->find("Application\Entity\User", 2);
     //         $engineer = $objectManager->find("Application\Entity\User", 3);
     //         if (!$reporter || !$engineer) {
     //             echo "No reporter and/or engineer found for the input.\n";
     //             exit(1);
     //         }
     //         $bug = new \Application\Entity\Bug();
     //         $bug->setDescription("Something does not work!");
     //         $bug->setCreated(new \DateTime("now"));
     //         $bug->setStatus("OPEN");
     //         foreach ($productIds as $productId) {
     //             $product = $objectManager->find("Application\Entity\Product", $productId);
     //             $bug->assignToProduct($product);
     //         }
     //         $bug->setReporter($reporter);
     //         $bug->setEngineer($engineer);
     //         $objectManager->persist($bug);
     //         $objectManager->flush();
     //         echo "Your new Bug Id: ".$bug->getId()."\n";
     //         $product = new \Application\Entity\Product();
     //         $product->setName('test');
     //         $objectManager->persist($product);
     //         $objectManager->flush();
     //         var_dump($product);
     //         Debug::dump($product);
     //         $objectManager->clear();
     //         $objectManager->close();
     return new ViewModel();
 }
 /**
  * Validates a request and takes a scope value that could result
  * in a user id being put into the request if it's valid.
  *
  * @param HttpFoundation\Request $request
  * @param string $scope
  * @return null|HttpFoundation\Response
  */
 public function validateRequest(HttpFoundation\Request $request, $scope)
 {
     $this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\OAuth', 'method' => 'validateRequest', 'type' => 'request', 'scope' => $scope]);
     $bridgeRequest = HttpFoundationBridge\Request::createFromRequest($request);
     if ($this->server->verifyResourceRequest($bridgeRequest, null, $scope)) {
         //Put the userId into the request if we're validating at the user scope
         if ($scope === 'user') {
             $token = $this->server->getAccessTokenData($bridgeRequest);
             $request->request->set('userId', $token['user_id']);
         } else {
             //Set the userId to 0 which should make any
             //searches relying on this being valid to fail.
             $request->request->set('userId', 0);
         }
         return null;
     }
     $this->log->addWarning('Failed to validate request', ['namespace' => 'HackTheDinos\\Controllers\\OAuth', 'method' => 'validateRequest', 'scope' => $scope]);
     return new HttpFoundation\Response('Not Authorized', 401);
 }
Пример #21
0
 /**
  * Shorten a URL.
  *
  * @param $url
  *
  * @return mixed
  */
 public function buildShortUrl($url)
 {
     if (!$this->shortnerServiceUrl) {
         return $url;
     }
     try {
         $response = $this->http->get($this->shortnerServiceUrl . urlencode($url));
         if ($response->code === 200) {
             return rtrim($response->body);
         } elseif ($this->logger) {
             $this->logger->addWarning("Url shortner failed with code {$response->code}: {$response->body}");
         }
     } catch (\Exception $exception) {
         if ($this->logger) {
             $this->logger->addError($exception->getMessage(), ['exception' => $exception]);
         }
     }
     return $url;
 }
 /**
  * Si debug active permite logear informacion
  * @param string $string Texto a mostrar
  * @param string $type Tipo de mensaje
  * @return void
  */
 public function _log($string, $type = 'info')
 {
     if ($type == 'info') {
         $this->log->addInfo($string);
     } elseif ($type == 'warning') {
         $this->log->addWarning($string);
     } elseif ($type == 'error') {
         $this->log->addError($string);
     }
 }
 /**
  * Handle the event.
  *
  * @param UpdateAvailable $event
  */
 public function handle(UpdateAvailable $event)
 {
     if (config('self-update.log_events')) {
         $this->logger->addInfo('[' . $event->getEventName() . '] event: Notification triggered.');
     }
     $sendToAddress = config('self-update.mail_to.address');
     $sendToName = config('self-update.mail_to.name');
     $subject = config('self-update.mail_to.subject_update_available');
     if (empty($sendToAddress)) {
         $this->logger->addCritical('[' . $event->getEventName() . '] event: ' . 'Missing recipient email address. Please set SELF_UPDATER_MAILTO_ADDRESS in your .env file.');
     }
     if (empty($sendToName)) {
         $this->logger->addWarning('[' . $event->getEventName() . '] event: ' . 'Missing recipient email name. Please set SELF_UPDATER_MAILTO_NAME in your .env file.');
     }
     $this->mailer->send('vendor.self-update.mails.update-available', ['newVersion' => $event->getVersionAvailable()], function ($m) use($subject, $sendToAddress, $sendToName) {
         $m->subject($subject);
         $m->from(config('mail.from.address'), config('mail.from.name'));
         $m->to($sendToAddress, $sendToName);
     });
 }
Пример #24
0
 public function traceLog($log_text, $error = false)
 {
     // create a log channel
     $log_text = print_r($log_text, true);
     $log      = new Logger('name');
     $log->pushHandler(new StreamHandler($this->log_file, Logger::WARNING));
     if (!$error)
         $log->addWarning($log_text);
     else
         $log->addError($log_text);
     
 }
 /**
  * @param CommunityInterface $community
  * @param Output             $output
  */
 private function updateCommunityMembers(CommunityInterface $community, Output $output)
 {
     $this->logger->addInfo(sprintf('Checking community "%s" with %s', $community->getName(), $community->getId()));
     $today = new \DateTime('-4 hour');
     $loopTimeStart = microtime(true);
     $failsCount = 0;
     $members = $community->getMembers();
     if ($output->isVerbose()) {
         $this->logger->addInfo(sprintf('Found %s members', count($members)));
     }
     foreach ($members as $player) {
         $memberTimeStart = microtime(true);
         $this->logger->addInfo(sprintf('Checking user "%s" with id "%s"', $player->getNick(), $player->getId()));
         $alreadyParseCheckTime = microtime(true);
         if (count($player->getDateStat()) && $player->getDateStat()->first()->getDate()->format('Y:m:d') == $today->format('Y:m:d')) {
             $this->logger->addInfo(sprintf('Player "%s" with id %s already parsed today', $player->getNick(), $player->getId()));
             if ($output->isVerbose()) {
                 $this->logger->addInfo(sprintf('Already parse check take %s sec to process', microtime(true) - $alreadyParseCheckTime));
             }
             continue;
         }
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Already parse check take %s sec to process', microtime(true) - $alreadyParseCheckTime));
         }
         $playerUpdateTimeStart = microtime(true);
         try {
             $this->statService->updatePlayer($player->getId());
         } catch (RuntimeException $e) {
             if ($e->getCode() == 403) {
                 $failsCount++;
                 if ($failsCount >= 10) {
                     throw $e;
                 }
                 $this->logger->addWarning(sprintf('Fail to update player "%s" with id %s', $player->getNick(), $player->getId()));
             } else {
                 throw $e;
             }
         }
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Player parse take %s sec to process', microtime(true) - $playerUpdateTimeStart));
         }
         $sleepMicroTime = rand(500, 1500) * 1000;
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Member take %s sec to process', microtime(true) - $memberTimeStart));
             $this->logger->addInfo(sprintf('Sleep for %s sec', $sleepMicroTime / 1000 / 1000));
         }
         usleep($sleepMicroTime);
     }
     if ($output->isVerbose()) {
         $this->logger->addInfo(sprintf('Loop take %s sec to process', microtime(true) - $loopTimeStart));
     }
 }
 /**
  * Connecting the iterator. Iterator counts repetitions, and generates a new line.
  */
 private function iterationProcess()
 {
     $log = new Logger('Compress algo logger');
     $log->pushHandler(new StreamHandler('comporess.log', Logger::WARNING));
     $values = str_split($this->sourceString);
     $log->addWarning($this->sourceString);
     $iterObj = new StringIterator($values);
     //        foreach ($iterObj as $a => $b) {
     //
     //        }
     $this->compressString = $iterObj->getStringCompress();
     $this->compressLength = strlen($this->compressString);
 }
 /**
  * Create a new picture
  *
  * @param HttpFoundation\Request $request
  * @return HttpFoundation\JsonResponse|HttpFoundation\Response
  */
 public function postIndex(HttpFoundation\Request $request)
 {
     $this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\Pictures', 'method' => 'postIndex', 'type' => 'request']);
     $path = 'uploads';
     $newfilename = date('Y-m-d_His') . '.jpg';
     if ($_FILES["picture"]["error"] === UPLOAD_ERR_OK) {
         $tmp_name = $_FILES["picture"]["tmp_name"];
         move_uploaded_file($tmp_name, "uploads/{$newfilename}");
     } else {
         return new HttpFoundation\Response($_FILES["picture"]["error"], 500);
     }
     // TODO create a model object
     $picture = new Models\Picture();
     $picture->filepath = $newfilename;
     // TODO save to DB
     if ($this->repo->save($picture)) {
         $this->log->addInfo('Created new picture', ['namespace' => 'HackTheDinos\\Controllers\\Picture', 'method' => 'postIndex', 'picture' => (array) $picture]);
         // TODO return picture db id
         return new HttpFoundation\JsonResponse($picture, 201);
     }
     $this->log->addWarning('Unable to create picture', ['namespace' => 'HackTheDinos\\Controllers\\Picture', 'method' => 'postIndex', 'request' => $request->getContent(), 'picture' => (array) $picture]);
     return new HttpFoundation\Response('Bad Request', 400);
 }
Пример #28
0
 /**
  * @test
  */
 public function it_correctly_identifies_the_info()
 {
     $bugsnag = new Bugsnag_Client(self::APIKEY);
     $logger = new Logger('my_logger');
     $logger->pushHandler(new BugsnagHandler(Logger::INFO, true, 'BugsnagMonolog', $bugsnag));
     $logger->addInfo('info', ['some' => 'message']);
     $logger->addError('error', ['some' => 'message']);
     $logger->addAlert('alert', ['some' => 'message']);
     $logger->addCritical('critical', ['some' => 'message']);
     $logger->addDebug('debug', ['some' => 'message']);
     $logger->addWarning('warning', ['some' => 'message']);
     $logger->addEmergency('emergency', ['some' => 'message']);
     $logger->addNotice('notice', ['some' => 'message']);
     $this->assertTrue(true);
 }
Пример #29
0
 public function getSearchPath()
 {
     $sql = "SHOW search_path";
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('search_path', 'search_path');
     $stmt = $this->em->createNativeQuery($sql, $rsm);
     $stmt->useResultCache(true, PgRetriever::CACHE_LIFETIME);
     $row = $stmt->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);
     $searchPath = [];
     if ($row) {
         $searchPath = explode(', ', $row['search_path']);
     } else {
         $this->logger->addWarning('No search path found!');
     }
     return $searchPath;
 }
 /**
  * @param int $fossilId
  * @param HttpFoundation\Request $request
  * @return HttpFoundation\JsonResponse|HttpFoundation\Response
  */
 public function postVotes($fossilId, HttpFoundation\Request $request)
 {
     $this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\Fossils', 'method' => 'postVotes', 'type' => 'request']);
     $fossil = $this->fossilRepo->getById($fossilId);
     if (is_null($fossil)) {
         $this->log->addWarning('Could not find fossil', ['namespace' => 'HackTheDinos\\Controllers\\Fossils', 'method' => 'postVotes', 'fossilId' => $fossilId]);
         return new HttpFoundation\Response('Dog Not Found', 400);
     }
     $vote = $this->converter->entityArrayToModel(json_decode($request->getContent(), true), new Models\Vote());
     $vote->fossilId = $fossil->id;
     if ($this->voteRepo->save($vote)) {
         $this->log->addInfo('Created new vote', ['namespace' => 'HackTheDinos\\Controllers\\Fossils', 'method' => 'postVote', 'fossil' => $fossil, 'vote' => $vote]);
         return new HttpFoundation\JsonResponse($vote, 201);
     }
     $this->log->addWarning('Unable to create vote', ['namespace' => 'HackTheDinos\\Controllers\\Fossils', 'method' => 'postVotes', 'request' => $request->getContent(), 'fossil' => $fossil, 'vote' => $vote]);
     return new HttpFoundation\Response('Bad Request', 400);
 }