本文整理匯總了PHP中Psr\Log\LoggerInterface::log方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerInterface::log方法的具體用法?PHP LoggerInterface::log怎麽用?PHP LoggerInterface::log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::log方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: log
/**
* @inheritdoc
*/
public function log($level, $message, array $context = array())
{
if ($this->isLevelLessThanMinimum($level)) {
return;
}
$this->logger->log($level, $message, $context);
}
示例2: dump
/**
* @param string $langPackDir language pack dir in temp folder
* @param string $projectNamespace e.g. Oro, OroCRM, etc
* @param string $outputFormat xml, yml, etc
* @param string $locale en, en_US, fr, etc
*/
public function dump($langPackDir, $projectNamespace, $outputFormat, $locale)
{
$this->preloadExistingTranslations($locale);
foreach ($this->bundles as $bundle) {
// skip bundles from other projects
if ($projectNamespace != $this->getBundlePrefix($bundle->getNamespace())) {
continue;
}
$this->logger->log(LogLevel::INFO, '');
$this->logger->log(LogLevel::INFO, sprintf('Writing files for <info>%s</info>', $bundle->getName()));
/** @var MessageCatalogue $currentCatalogue */
$currentCatalogue = $this->getCurrentCatalog($locale, $bundle->getName());
$extractedCatalogue = $this->extractViewTranslationKeys($locale, $bundle->getPath());
$operation = new MergeOperation($currentCatalogue, $extractedCatalogue);
$messageCatalogue = $operation->getResult();
$isEmptyCatalogue = $this->validateAndFilter($messageCatalogue);
if (!$isEmptyCatalogue) {
$translationsDir = $langPackDir . DIRECTORY_SEPARATOR . $bundle->getName() . DIRECTORY_SEPARATOR . 'translations';
$this->filesystem->mkdir($translationsDir);
$this->writer->writeTranslations($messageCatalogue, $outputFormat, ['path' => $translationsDir]);
} else {
$this->logger->log(LogLevel::INFO, ' - no files generated');
}
}
}
示例3: log
/**
* Write a message to the log or skip over it if the message is null
*
* @param string $logLevel
* @param string|null $message
*/
protected function log($logLevel, $message)
{
if ($message === null) {
return;
}
$this->logger->log($logLevel, $message);
}
示例4: __construct
public function __construct($message = \null, $code = \null, $previous = \null)
{
parent::__construct($message, $code, $previous);
if (static::$logger !== \null) {
static::$logger->log(LogLevel::ALERT, $message, array('code' => $this->getCode(), 'message' => $this->getMessage(), 'file' => $this->getFile(), 'line' => $this->getLine(), 'type' => 'exceptions'));
}
}
示例5: log
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = array())
{
if ($this->logger) {
$this->logger->log($level, $message, $context);
}
return $this;
}
示例6: log
public function log($message, array $context = array(), $level = LogLevel::DEBUG)
{
if (!isset($this->logger)) {
return;
}
$this->logger->log($level, $message, $context);
}
示例7: onPreHttpRequestSend
/**
* @param \Neoxygen\NeoClient\Event\HttpClientPreSendRequestEvent $event
*/
public function onPreHttpRequestSend(HttpClientPreSendRequestEvent $event)
{
$conn = $event->getRequest()->getConnection();
$request = $event->getRequest();
$mode = $request->hasQueryMode() ? $request->getQueryMode() : 'ASSUMED WRITE';
$this->logger->log('debug', sprintf('Sending "%s" request to the "%s" connection', $mode, $conn));
}
示例8: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
if (null === $this->logger) {
return;
}
$add = true;
$stackTrace = $this->getStackTrace();
if (null !== $this->stopwatch) {
$trace = debug_backtrace();
$method = $trace[3]['function'];
$watch = 'Propel Query ' . (count($this->queries) + 1);
if ('prepare' === $method) {
$this->isPrepared = true;
$this->stopwatch->start($watch, 'propel');
$add = false;
} elseif ($this->isPrepared) {
$this->isPrepared = false;
$event = $this->stopwatch->stop($watch);
}
}
// $trace[2] has no 'object' key if an exception is thrown while executing a query
if ($add && isset($event) && isset($trace[2]['object'])) {
$connection = $trace[2]['object'];
$this->queries[] = array('sql' => $message, 'connection' => $connection->getName(), 'time' => $event->getDuration() / 1000, 'memory' => $event->getMemory(), 'stackTrace' => $stackTrace);
}
$this->logger->log($level, $message, $context);
}
示例9: log
/**
* Записывает сообщение в лог.
* @param string $level уровень критичности сообщения
* @param string $message сообщение, поддерживает плейсхолдеры в формате {placeholder}
* @param array $placeholders список плейсхолдеров
* @return $this
*/
protected function log($level, $message, array $placeholders = [])
{
if ($this->traitLogger) {
$this->traitLogger->log($level, $message, $placeholders);
}
return $this;
}
示例10: log
/**
* Adds the message prefix and invokes the logger->log() method.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return void
*/
private function log($level, $message, array $context = array())
{
// Using a falsy level disables logging
if ($level) {
$this->logger->log($level, $this->prefix . $message, $context);
}
}
示例11: getForm
/**
* {@inheritdoc}
*/
public function getForm($formClass)
{
$args = func_get_args();
array_shift($args);
if (!class_exists($formClass)) {
$this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not exists", ['@class' => $formClass]);
return [];
}
if (!method_exists($formClass, 'create')) {
$this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not implements ::create()", ['@class' => $formClass]);
return [];
}
// God, I do hate Drupal 8...
$form = call_user_func([$formClass, 'create'], $this->container);
if (!$form instanceof FormInterface) {
$this->logger->log(LogLevel::CRITICAL, "Form class '@class' does not implement \\Drupal\\Core\\Form\\FormInterface", ['@class' => $formClass]);
return [];
}
$formId = $form->getFormId();
$data = [];
$data['build_info']['args'] = $args;
$formState = new FormState($data);
$formState->setFormObject($form);
$this->formMap[$formId] = [$form, $formState];
return drupal_build_form($formId, $data);
}
示例12: log
/**
* Log payment message, prepending payment bundle name if set.
*
* @param string $level Level
* @param string $message Message to log
* @param string $paymentMethod Payment method
* @param array $context Context
*
* @return PaymentLogger Self object
*/
public function log($level, $message, $paymentMethod, array $context = [])
{
if (!$this->active) {
return $this;
}
$this->logger->log($level, "[{$paymentMethod}] - {$message}", $context);
return $this;
}
示例13: handleException
/**
* handleException
*
* Handles Exceptions
*
* @access public
* @param Exception $exception
* @return void
* @todo Make default / fallback log level configurable
**/
public function handleException(Exception $exception)
{
if (method_exists($exception, "getSeverityLevel")) {
$this->logger->log($exception->getSeverityLevel(), $exception->getMessage(), $this->getExceptionContext($exception));
} else {
$this->logger->critical($exception->getMessage(), $this->getExceptionContext($exception));
}
}
示例14: handle
/**
* {@inheritDoc}
*/
public function handle(array $record)
{
if (!$this->isHandling($record)) {
return false;
}
$this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']);
return false === $this->bubble;
}
示例15: testSendMailToTwoRecipients
/**
* Tests sending a mail to two recipients.
*
* @covers ::execute
*/
public function testSendMailToTwoRecipients()
{
$to = ['mail@example.com', 'mail2@example.com'];
$this->action->setContextValue('to', $to)->setContextValue('subject', 'subject')->setContextValue('message', 'hello');
$params = ['subject' => 'subject', 'message' => 'hello'];
$this->mailManager->mail('rules', 'rules_action_mail_' . $this->action->getPluginId(), implode(', ', $to), LanguageInterface::LANGCODE_SITE_DEFAULT, $params, NULL)->willReturn(['result' => TRUE])->shouldBeCalledTimes(1);
$this->logger->log(LogLevel::NOTICE, SafeMarkup::format('Successfully sent email to %to', ['%to' => implode(', ', $to)]))->shouldBeCalledTimes(1);
$this->action->execute();
}