You are here

public function ImagemagickExecManager::debugMessage in ImageMagick 8.3

Same name and namespace in other branches
  1. 8.2 src/ImagemagickExecManager.php \Drupal\imagemagick\ImagemagickExecManager::debugMessage()

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 ImagemagickExecManager::debugMessage()
ImagemagickExecManager::runOsShell in src/ImagemagickExecManager.php
Executes a command on the operating system.

File

src/ImagemagickExecManager.php, line 379

Class

ImagemagickExecManager
Manage execution of ImageMagick/GraphicsMagick commands.

Namespace

Drupal\imagemagick

Code

public function debugMessage(string $message, array $context) {
  $this->logger
    ->debug($message, $context);
  if ($this->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);
      }
    }

    // @codingStandardsIgnoreLine
    $this->messenger
      ->addMessage($this
      ->t($message, $context), 'status', TRUE);
  }
}