Exemple #1
0
 public function logException()
 {
     try {
         //			$user = $this->getServiceManager()->get('CurrentUser');
         foreach (func_get_args() as $info) {
             if (is_object($info)) {
                 /** @var \Exception $info */
                 $message = sprintf($this->exceptionTpl, get_class($info), $info->getMessage(), $info->getFile(), $info->getLine(), $info->getTraceAsString());
             } else {
                 $message = sprintf($this->errorTpl, array_shift($info), array_shift($info), array_shift($info), array_shift($info));
             }
             //
             //				if ($user && $user->isAuth()) {
             //					$message .= "Пользователь(user_id): {$user->getId()}\n";
             //					$message .= "Организация(firm_id): {$user->getFirmId()}\n";
             //				}
             if (isset($_SERVER['REQUEST_URI'])) {
                 $message .= "Url: {$_SERVER['REQUEST_URI']}\n";
             }
             $message .= "\n";
             $this->logger->err($message);
         }
     } catch (\Exception $e) {
         // nothing ...
     }
 }
Exemple #2
0
 /**
  * Log de erro
  * @param  string $pathLog caminho do erro
  * @param  string $message mensagem de erro
  * @return boolean
  */
 public static function err($pathLog, $message)
 {
     self::createLogger();
     self::$logger->addWriter(new \Zend\Log\Writer\Stream($pathLog . DIRECTORY_SEPARATOR . "err.log"));
     self::$logger->err($message);
     self::destroyLogger();
     return TRUE;
 }
 /**
  * Output a message with a timestamp
  *
  * @param string  $msg   Message
  * @param boolean $error Log as en error message?
  *
  * @return void
  */
 protected function msg($msg, $error = false)
 {
     $msg = '[' . getmypid() . "] {$msg}";
     if ($error) {
         $this->errLogger->err($msg);
         $this->logger->err($msg);
     } else {
         $this->logger->info($msg);
     }
 }
Exemple #4
0
 /**
  * @param \Exception $exc
  */
 public function logException(\Exception $exc)
 {
     $log = "Exception:\n";
     $trace = "\nTrace:\n" . $exc->getTraceAsString();
     $count = 1;
     do {
         $log .= $count++ . ": " . $exc->getMessage() . "\n";
     } while ($exc = $exc->getPrevious());
     $log .= $trace;
     $this->logger->err($log);
 }
 /**
  * @return string
  */
 public function registerAction()
 {
     $userData = ['email' => $this->params('email', false), 'password' => $this->params('password', false), 'passwordVerify' => $this->params('password', false), 'username' => $this->params('username', false), 'display_name' => $this->params('display_name', false)];
     $user = $this->userService->register($userData);
     if (!$user) {
         $this->logger->err('User registration failed.');
         $this->logIssues();
     } else {
         $this->logger->info('User is registered successfully.');
     }
     return '';
 }
 /**
  * 
  * @param EventInterface $event
  */
 public function log(EventInterface $event)
 {
     $exception = $event->getResult()->exception;
     if (!$exception) {
         return;
     }
     $trace = $exception->getTraceAsString();
     $i = 1;
     do {
         $messages[] = $i++ . ": " . $exception->getMessage();
     } while ($e = $exception->getPrevious());
     $log = "Exception:n" . implode("n", $messages);
     $log .= "nTrace:n" . $trace;
     $this->logger->err($log);
 }
 /**
  * @return string
  */
 public function sendAction()
 {
     $queueSize = $this->options->getQueueSize();
     $throttleSize = $this->mailThrottle->getThrottleSize();
     if ($queueSize < 1 || 0 === $throttleSize) {
         $this->logger->err('Can not send anything.');
         return '';
     }
     $currentQueueSize = $throttleSize > 0 ? min($queueSize, $throttleSize) : $queueSize;
     $readyQueue = $this->queueItemRepository->getReadyQueue($currentQueueSize);
     $this->processQueueToSend($readyQueue);
     if ($this->hasCacheStorage()) {
         $this->cacheStorage->setItem(\DmMailer\View\DataProvider\Kpi::CS_LAST_MESSAGE_SENDING, $this->getTime());
     }
     return '';
 }
 /**
  *
  * @param string $message            
  * @param array $extra            
  */
 public static function logError($message, array $extra = array())
 {
     if (is_null(self::$logger)) {
         throw new ProcessException("Impossible de loguer le message d'erreur : " . $message);
     }
     self::$logger->err($message, $extra);
 }
Exemple #9
0
 /**
  * Callback function invoking on mail sending error
  *
  * @param Event $e
  */
 public function onMailSentError(Event $e)
 {
     /* @var Message */
     $message = $e->getTarget();
     $params = $e->getParams();
     $addressList = $this->prepareAddressList($message);
     $this->logger->err(sprintf("E-mail '%s' has been not sent to following recipients: %s. Error message: %s", $message->getSubject(), implode(', ', $addressList), $params['error_message']));
 }
Exemple #10
0
 /**
  * @param QueueItem[] $queue
  * @param bool        $testMail
  *
  * @return int
  */
 public function process(array $queue, $testMail = false)
 {
     $sentCount = 0;
     foreach ($queue as $queueItem) {
         if ($testMail && !$queueItem->isSystemMessage()) {
             continue;
         }
         try {
             $this->safeSend($queueItem);
         } catch (\Exception $ex) {
             $message = "Failure sending queue item #" . $queueItem->getId() . ": " . $ex->getMessage();
             $message .= $ex->getTraceAsString();
             $this->logger->err($message);
         }
         $this->log();
         $sentCount++;
     }
     return $sentCount;
 }
 public function run()
 {
     while (true) {
         try {
             $this->loadAddresses();
             //aby načetl nově generované adresy
             $this->client->open();
             $this->loop->run();
         } catch (\Exception $e) {
             $this->logger->err($e->getMessage());
         }
     }
 }
 /**
  * Log an error
  *
  * @param string $errorMessage
  * @return boolean
  */
 public static function log($errorMessage)
 {
     try {
         $writer = new LogWriterStream(ServiceLocatorService::getServiceLocator()->get('Config')['paths']['error_log']);
         $logger = new Logger();
         $logger->addWriter($writer);
         $logger->err($errorMessage);
         // do we need send this error via email?
         if (null != ($errorEmail = SettingService::getSetting('application_errors_notification_email'))) {
             ApplicationEmailNotification::sendNotification($errorEmail, SettingService::getSetting('application_error_notification_title', LocalizationService::getDefaultLocalization()['language']), SettingService::getSetting('application_error_notification_message', LocalizationService::getDefaultLocalization()['language']), ['find' => ['ErrorDescription'], 'replace' => [$errorMessage]]);
         }
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
file_put_contents($sessionFile, Json::encode($storedData));
//end of security check
$songProvider = new SongProvider($host, $dbName, $username, $password, $songsDirectory, $webSongsDir, $port);
$msg = $_GET['request'];
if ($msg == 'getSongs') {
    $songData['songs'] = $songProvider->readNonProcessedSongs();
} else {
    if ($msg == 'emptyQueue') {
        $currentGenreId = file_get_contents($currentGenreFile);
        $songData['songs'] = [$songProvider->getRandomSong($currentGenreId)];
        //abych měl jednoprvkové pole
    }
}
$songData['request'] = $msg;
$data = null;
try {
    $data = Json::encode($songData);
} catch (JsonException $e) {
    //	$songs = $songData['songs'];
    //	$songsString = '';
    //	/** @var Song $song */
    //	foreach ($songs as $song) {
    //		$songData
    //	}
    $logger = new Logger();
    $fileWriter = new Stream("log.txt");
    $logger->addWriter($fileWriter);
    $logger->err("Json encoding failed: reason:" . $e->getMessage());
    $logger->err('data: ' . implode(', ', Arrays::flatten($songData)));
}
echo $data;
 public function logError($message)
 {
     $this->logger->err($message);
     error_log($message);
 }
Exemple #15
0
 /**
  * @param  string $msg
  * @return \Zend\Log\Logger
  */
 public function logError($msg)
 {
     return $this->logger->err($msg);
 }