You are here

public function ImagemagickToolkit::debugMessage in ImageMagick 8

Logs a debug message, and shows it on the screen for authorized users.

Parameters

string $message: The debug message.

string[] $context: Context information.

1 call to ImagemagickToolkit::debugMessage()
ImagemagickToolkit::runOsShell in src/Plugin/ImageToolkit/ImagemagickToolkit.php
Executes a command on the operating system.

File

src/Plugin/ImageToolkit/ImagemagickToolkit.php, line 1335

Class

ImagemagickToolkit
Provides ImageMagick integration toolkit for image manipulation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit

Code

public function debugMessage($message, array $context) {
  $this->logger
    ->debug($message, $context);
  if (\Drupal::currentUser()
    ->hasPermission('administer site configuration')) {

    // Strips raw text longer than 10 lines to optimize displaying.
    if (isset($context['@raw'])) {
      $raw = explode("\n", $context['@raw']);
      if (count($raw) > 10) {
        $tmp = [];
        for ($i = 0; $i < 9; $i++) {
          $tmp[] = $raw[$i];
        }
        $tmp[] = (string) $this
          ->t('[Further text stripped. The watchdog log has the full text.]');
        $context['@raw'] = implode("\n", $tmp);
      }
    }
    drupal_set_message($this
      ->t($message, $context), 'status', TRUE);
  }
}