本文整理匯總了PHP中Zend\Log\Logger::err方法的典型用法代碼示例。如果您正苦於以下問題:PHP Logger::err方法的具體用法?PHP Logger::err怎麽用?PHP Logger::err使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Log\Logger
的用法示例。
在下文中一共展示了Logger::err方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: logException
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 ...
}
}
示例2: err
/**
* 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;
}
示例3: msg
/**
* 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);
}
}
示例4: logException
/**
* @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);
}
示例5: registerAction
/**
* @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 '';
}
示例6: log
/**
*
* @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);
}
示例7: sendAction
/**
* @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 '';
}
示例8: logError
/**
*
* @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);
}
示例9: onMailSentError
/**
* 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']));
}
示例10: process
/**
* @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;
}
示例11: run
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());
}
}
}
示例12: log
/**
* 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;
}
示例13: SongProvider
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;
示例14: logError
public function logError($message)
{
$this->logger->err($message);
error_log($message);
}
示例15: logError
/**
* @param string $msg
* @return \Zend\Log\Logger
*/
public function logError($msg)
{
return $this->logger->err($msg);
}