Commit a91ef2b8 authored by catch's avatar catch

Issue #2272481 by herom, ParisLiakos, tim.plunkett: Remove usages of...

Issue #2272481 by herom, ParisLiakos, tim.plunkett: Remove usages of watchdog() from forms, plugins and controllers.
parent ced85d10
......@@ -176,6 +176,11 @@ services:
factory_method: get
factory_service: logger.factory
arguments: ['system']
logger.channel.image:
class: Drupal\Core\Logger\LoggerChannel
factory_method: get
factory_service: logger.factory
arguments: ['image']
logger.log_message_parser:
class: Drupal\Core\Logger\LogMessageParser
......@@ -741,9 +746,10 @@ services:
- { name: event_subscriber }
image.toolkit.manager:
class: Drupal\Core\ImageToolkit\ImageToolkitManager
arguments: ['@container.namespaces', '@cache.discovery', '@config.factory', '@module_handler', '@image.toolkit.operation.manager']
arguments: ['@container.namespaces', '@cache.discovery', '@config.factory', '@module_handler', '@image.toolkit.operation.manager', '@logger.channel.image']
image.toolkit.operation.manager:
class: Drupal\Core\ImageToolkit\ImageToolkitOperationManager
arguments: ['@logger.channel.image']
parent: default_plugin_manager
image.factory:
class: Drupal\Core\Image\ImageFactory
......
......@@ -640,7 +640,7 @@ public static function isConfigSyncing() {
* The name of the channel. Can be any string, but the general practice is
* to use the name of the subsystem calling this.
*
* @return \Drupal\Core\Logger\LoggerChannelInterface
* @return \Psr\Log\LoggerInterface
* The logger for this channel.
*/
public static function logger($channel) {
......
......@@ -46,6 +46,13 @@ abstract class FormBase implements FormInterface, ContainerInjectionInterface {
*/
protected $configFactory;
/**
* The logger factory.
*
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $loggerFactory;
/**
* {@inheritdoc}
*/
......@@ -187,4 +194,20 @@ protected function setFormError($name, FormStateInterface $form_state, $message
return $this;
}
/**
* Gets the logger for a specific channel.
*
* @param string $channel
* The name of the channel.
*
* @return \Psr\Log\LoggerInterface
* The logger for this channel.
*/
protected function logger($channel) {
if (!$this->loggerFactory) {
$this->loggerFactory = $this->container()->get('logger.factory');
}
return $this->loggerFactory->get($channel);
}
}
......@@ -10,6 +10,7 @@
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Image\ImageInterface;
use Drupal\Core\Plugin\PluginBase;
use Psr\Log\LoggerInterface;
abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterface {
......@@ -27,6 +28,14 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf
*/
protected $operationManager;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs an ImageToolkitBase object.
*
......@@ -38,10 +47,13 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf
* The plugin implementation definition.
* @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager
* The toolkit operation manager.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->operationManager = $operation_manager;
$this->logger = $logger;
}
/**
......@@ -90,11 +102,11 @@ public function apply($operation, array $arguments = array()) {
return $this->getToolkitOperation($operation)->apply($arguments);
}
catch (PluginNotFoundException $e) {
\Drupal::logger('image')->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", array('@toolkit' => $this->getPluginId(), '@operation' => $operation));
$this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", array('@toolkit' => $this->getPluginId(), '@operation' => $operation));
return FALSE;
}
catch (\InvalidArgumentException $e) {
\Drupal::logger('image')->warning($e->getMessage(), array());
$this->logger->warning($e->getMessage(), array());
return FALSE;
}
}
......
......@@ -12,6 +12,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Psr\Log\LoggerInterface;
/**
* Manages toolkit plugins.
......@@ -32,6 +33,13 @@ class ImageToolkitManager extends DefaultPluginManager {
*/
protected $operationManager;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs the ImageToolkitManager object.
*
......@@ -46,13 +54,16 @@ class ImageToolkitManager extends DefaultPluginManager {
* The module handler.
* @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager
* The toolkit operation manager.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ImageToolkitOperationManagerInterface $operation_manager) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger) {
parent::__construct('Plugin/ImageToolkit', $namespaces, $module_handler, 'Drupal\Core\ImageToolkit\Annotation\ImageToolkit');
$this->setCacheBackend($cache_backend, 'image_toolkit_plugins');
$this->configFactory = $config_factory;
$this->operationManager = $operation_manager;
$this->logger = $logger;
}
/**
......@@ -115,7 +126,7 @@ public function getAvailableToolkits() {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
return new $plugin_class($configuration, $plugin_id, $plugin_definition, $this->operationManager);
return new $plugin_class($configuration, $plugin_id, $plugin_definition, $this->operationManager, $this->logger);
}
}
......@@ -10,6 +10,7 @@
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Utility\String;
use Drupal\Core\Plugin\PluginBase;
use Psr\Log\LoggerInterface;
abstract class ImageToolkitOperationBase extends PluginBase implements ImageToolkitOperationInterface {
......@@ -20,6 +21,13 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
*/
protected $toolkit;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs an image toolkit operation plugin.
*
......@@ -31,10 +39,13 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
* The plugin implementation definition.
* @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit
* The image toolkit.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitInterface $toolkit) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitInterface $toolkit, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->toolkit = $toolkit;
$this->logger = $logger;
}
/**
......
......@@ -13,12 +13,20 @@
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Utility\String;
use Psr\Log\LoggerInterface;
/**
* Manages toolkit operation plugins.
*/
class ImageToolkitOperationManager extends DefaultPluginManager implements ImageToolkitOperationManagerInterface {
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs the ImageToolkitOperationManager object.
*
......@@ -29,12 +37,15 @@ class ImageToolkitOperationManager extends DefaultPluginManager implements Image
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LoggerInterface $logger) {
parent::__construct('Plugin/ImageToolkit/Operation', $namespaces, $module_handler, 'Drupal\Core\ImageToolkit\Annotation\ImageToolkitOperation');
$this->alterInfo('image_toolkit_operation');
$this->setCacheBackend($cache_backend, 'image_toolkit_operation_plugins');
$this->logger = $logger;
}
/**
......@@ -79,7 +90,7 @@ function ($definition) use ($toolkit_id, $operation) {
public function createInstance($plugin_id, array $configuration = array(), ImageToolkitInterface $toolkit = NULL) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
return new $plugin_class($configuration, $plugin_id, $plugin_definition, $toolkit);
return new $plugin_class($configuration, $plugin_id, $plugin_definition, $toolkit, $this->logger);
}
/**
......
......@@ -43,7 +43,7 @@ public function getCancelUrl() {
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label()));
$this->logger('user')->notice('Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label()));
drupal_set_message($this->t('Action %action was deleted', array('%action' => $this->entity->label())));
$form_state['redirect_route'] = $this->getCancelUrl();
......
......@@ -12,6 +12,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Utility\Token;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -39,6 +40,13 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
*/
protected $storage;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a EmailAction object.
*
......@@ -52,12 +60,15 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
* The token service.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityManagerInterface $entity_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityManagerInterface $entity_manager, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->token = $token;
$this->storage = $entity_manager->getStorage('user');
$this->logger = $logger;
}
/**
......@@ -66,7 +77,8 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition,
$container->get('token'),
$container->get('entity.manager')
$container->get('entity.manager'),
$container->get('logger.factory')->get('action')
);
}
......@@ -94,10 +106,10 @@ public function execute($entity = NULL) {
$params = array('context' => $this->configuration);
if (drupal_mail('system', 'action_send_email', $recipient, $langcode, $params)) {
watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
$this->logger->notice('Sent email to %recipient', array('%recipient' => $recipient));
}
else {
watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
$this->logger->error('Unable to send email to %recipient', array('%recipient' => $recipient));
}
}
......
......@@ -70,7 +70,7 @@ public function save(array $form, FormStateInterface $form_state) {
$form_state['redirect_route'] = $feed->urlInfo('canonical');
}
else {
watchdog('aggregator', 'Feed %feed added.', array('%feed' => $feed->label()), WATCHDOG_NOTICE, l($this->t('View'), 'admin/config/services/aggregator'));
$this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => l($this->t('View'), 'admin/config/services/aggregator')));
drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $feed->label())));
}
}
......
......@@ -42,7 +42,7 @@ public function getConfirmText() {
*/
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label()));
$this->logger('aggregator')->notice('Feed %feed deleted.', array('%feed' => $this->entity->label()));
drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label())));
$form_state['redirect_route'] = new Url('aggregator.sources');
}
......
......@@ -125,7 +125,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$data = $response->getBody(TRUE);
}
catch (RequestException $e) {
watchdog('aggregator', 'Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()), WATCHDOG_WARNING);
$this->logger('aggregator')->warning('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()));
drupal_set_message($this->t('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage())));
return;
}
......
......@@ -13,6 +13,7 @@
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -35,14 +36,24 @@ class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterfac
*/
protected $httpClient;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a DefaultFetcher object.
*
* @param \GuzzleHttp\ClientInterface $http_client
* A Guzzle client object.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(ClientInterface $http_client) {
public function __construct(ClientInterface $http_client, LoggerInterface $logger) {
$this->httpClient = $http_client;
$this->logger = $logger;
}
/**
......@@ -50,7 +61,8 @@ public function __construct(ClientInterface $http_client) {
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$container->get('http_client')
$container->get('http_client'),
$container->get('logger.factory')->get('aggregator')
);
}
......@@ -91,7 +103,7 @@ public function fetch(FeedInterface $feed) {
return TRUE;
}
catch (RequestException $e) {
watchdog('aggregator', 'The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage()), WATCHDOG_WARNING);
$this->logger->warning('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage()));
drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())) , 'warning');
return FALSE;
}
......
......@@ -91,7 +91,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $ban_id =
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->ipManager->unbanIp($this->banIp);
watchdog('user', 'Deleted %ip', array('%ip' => $this->banIp));
$this->logger('user')->notice('Deleted %ip', array('%ip' => $this->banIp));
drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp)));
$form_state['redirect_route'] = $this->getCancelUrl();
}
......
......@@ -194,16 +194,17 @@ public function save(array $form, FormStateInterface $form_state) {
$block = $this->entity;
$insert = $block->isNew();
$block->save();
$watchdog_args = array('@type' => $block->bundle(), '%info' => $block->label());
$context = array('@type' => $block->bundle(), '%info' => $block->label());
$logger = $this->logger('block_content');
$block_type = entity_load('block_content_type', $block->bundle());
$t_args = array('@type' => $block_type->label(), '%info' => $block->label());
if ($insert) {
watchdog('content', '@type: added %info.', $watchdog_args, WATCHDOG_NOTICE);
$logger->notice('@type: added %info.', $context);
drupal_set_message($this->t('@type %info has been created.', $t_args));
}
else {
watchdog('content', '@type: updated %info.', $watchdog_args, WATCHDOG_NOTICE);
$logger->notice('@type: updated %info.', $context);
drupal_set_message($this->t('@type %info has been updated.', $t_args));
}
......
......@@ -93,13 +93,14 @@ public function save(array $form, FormStateInterface $form_state) {
$status = $block_type->save();
$edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
$logger = $this->logger('block_content');
if ($status == SAVED_UPDATED) {
drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label())));
watchdog('block_content', 'Custom block type %label has been updated.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link);
$logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link));
}
else {
drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label())));
watchdog('block_content', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link);
$logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link));
}
$form_state['redirect_route']['route_name'] = 'block_content.type_list';
......
......@@ -57,7 +57,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('block_content', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$this->logger('block_content')->notice('Custom block %label has been deleted.', array('%label' => $this->entity->label()));
$form_state['redirect_route'] = new Url('block_content.list');
}
......
......@@ -86,7 +86,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('block_content', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$this->logger('block_content')->notice('Custom block type %label has been deleted.', array('%label' => $this->entity->label()));
$form_state['redirect_route'] = $this->getCancelUrl();
}
......
......@@ -120,7 +120,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$node->book['link_title'] = $values['title'];
$node->setNewRevision();
$node->save();
watchdog('content', 'book: updated %title.', array('%title' => $node->label()), WATCHDOG_NOTICE, l($this->t('View'), 'node/' . $node->id()));
$this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => l($this->t('View'), 'node/' . $node->id())));
}
}
}
......
......@@ -364,6 +364,7 @@ public function save(array $form, FormStateInterface $form_state) {
$entity = $comment->getCommentedEntity();
$field_name = $comment->getFieldName();
$uri = $entity->urlInfo();
$logger = $this->logger('content');
if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) {
// Save the anonymous user information to a cookie for reuse.
......@@ -374,8 +375,8 @@ public function save(array $form, FormStateInterface $form_state) {
$comment->save();
$form_state['values']['cid'] = $comment->id();
// Add an entry to the watchdog log.
watchdog('content', 'Comment posted: %subject.', array('%subject' => $comment->getSubject()), WATCHDOG_NOTICE, l(t('View'), 'comment/' . $comment->id(), array('fragment' => 'comment-' . $comment->id())));
// Add a log entry.
$logger->notice('Comment posted: %subject.', array('%subject' => $comment->getSubject(), 'link' => l(t('View'), 'comment/' . $comment->id(), array('fragment' => 'comment-' . $comment->id()))));
// Explain the approval queue if necessary.
if (!$comment->isPublished()) {
......@@ -398,7 +399,7 @@ public function save(array $form, FormStateInterface $form_state) {
$uri->setOption('fragment', 'comment-' . $comment->id());
}
else {
watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject()), WATCHDOG_WARNING);
$logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject()));
drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())), 'error');
// Redirect the user to the entity they are commenting on.
}
......
......@@ -121,7 +121,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state['values']['confirm']) {
$this->commentStorage->delete($this->comments);
$count = count($form_state['values']['comments']);
watchdog('content', 'Deleted @count comments.', array('@count' => $count));
$this->logger('content')->notice('Deleted @count comments.', array('@count' => $count));
drupal_set_message(format_plural($count, 'Deleted 1 comment.', 'Deleted @count comments.'));
}
$form_state['redirect_route'] = $this->getCancelUrl();
......
......@@ -51,7 +51,7 @@ public function submit(array $form, FormStateInterface $form_state) {
// Delete the comment and its replies.
$this->entity->delete();
drupal_set_message($this->t('The comment and all its replies have been deleted.'));
watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $this->entity->id()));
$this->logger('content')->notice('Deleted comment @cid and its replies.', array('@cid' => $this->entity->id()));
$form_state['redirect_route'] = $this->getCancelUrl();
}
......
......@@ -100,11 +100,11 @@ public function save(array $form, FormStateInterface $form_state) {
if ($status == SAVED_UPDATED) {
drupal_set_message($this->t('Category %label has been updated.', array('%label' => $category->label())));
watchdog('contact', 'Category %label has been updated.', array('%label' => $category->label()), WATCHDOG_NOTICE, $edit_link);
$this->logger('contact')->notice('Category %label has been updated.', array('%label' => $category->label(), 'link' => $edit_link));
}
else {
drupal_set_message($this->t('Category %label has been added.', array('%label' => $category->label())));
watchdog('contact', 'Category %label has been added.', array('%label' => $category->label()), WATCHDOG_NOTICE, $edit_link);
$this->logger('contact')->notice('Category %label has been added.', array('%label' => $category->label(), 'link' => $edit_link));
}
// Update the default category.
......
......@@ -43,7 +43,7 @@ public function getConfirmText() {
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message($this->t('Category %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('contact', 'Category %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$this->logger('contact')->notice('Category %label has been deleted.', array('%label' => $this->entity->label()));
$form_state['redirect_route'] = $this->getCancelUrl();
}
......
......@@ -239,14 +239,14 @@ public function save(array $form, FormStateInterface $form_state) {
$this->flood->register('contact', $this->config('contact.settings')->get('flood.interval'));
if (!$message->isPersonal()) {
watchdog('contact', '%sender-name (@sender-from) sent an email regarding %category.', array(
$this->logger('contact')->notice('%sender-name (@sender-from) sent an email regarding %category.', array(
'%sender-name' => $sender->getUsername(),
'@sender-from' => $sender->getEmail(),
'%category' => $category->label(),
));
}
else {
watchdog('contact', '%sender-name (@sender-from) sent %recipient-name an email.', array(
$this->logger('contact')->notice('%sender-name (@sender-from) sent %recipient-name an email.', array(
'%sender-name' => $sender->getUsername(),
'@sender-from' => $sender->getEmail(),
'%recipient-name' => $message->getPersonalRecipient()->getUsername(),
......
......@@ -40,7 +40,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
// Once per filter, log that a filter plugin was missing.
if (!$this->logged) {
$this->logged = TRUE;
watchdog('filter', 'Missing filter plugin: %filter.', array('%filter' => $plugin_id), WATCHDOG_ALERT);
\Drupal::logger('filter')->alert('Missing filter plugin: %filter.', array('%filter' => $plugin_id));
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
......
......@@ -67,7 +67,7 @@ public function buildForm(array $form, FormStateInterface $form_state, TermInter
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->taxonomyTerm->delete();
drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label())));
watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE);
$this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()));
$form_state['redirect_route'] = $this->getCancelUrl();
}
......
......@@ -82,13 +82,13 @@ public function save(array $form, FormStateInterface $form_state) {
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
watchdog('forum', 'Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
$this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())));
$form_state['values']['tid'] = $term->id();
break;
case SAVED_UPDATED:
drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
watchdog('taxonomy', 'Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
$this->logger('forum')->notice('Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())));
break;
}
......
......@@ -12,6 +12,7 @@
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\image\ImageStyleInterface;
use Drupal\system\FileDownloadController;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
......@@ -38,6 +39,13 @@ class ImageStyleDownloadController extends FileDownloadController {
*/
protected $imageFactory;
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a ImageStyleDownloadController object.
*
......@@ -45,10 +53,13 @@ class ImageStyleDownloadController extends FileDownloadController {
* The lock backend.
* @param \Drupal\Core\Image\ImageFactory $image_factory
* The image factory.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(LockBackendInterface $lock, ImageFactory $image_factory) {
public function __construct(LockBackendInterface $lock, ImageFactory $image_factory, LoggerInterface $logger) {
$this->lock = $lock;
$this->imageFactory = $image_factory;
$this->logger = $logger;
}