You are here

VarDumperWatchdog.php in VarDumper 8

Same filename and directory in other branches
  1. 7 modules/vardumper_watchdog/src/VarDumper/VarDumperWatchdog.php

File

modules/vardumper_watchdog/src/VarDumper/VarDumperWatchdog.php
View source
<?php

namespace Drupal\vardumper_watchdog\VarDumper;

use Drupal\vardumper\VarDumper\VarDumperDebug;

/**
 * The VarDumperWatchdog class.
 */
class VarDumperWatchdog extends VarDumperDebug {

  /**
   * {@inheritdoc}
   */
  public function dump($var, $name = '') {

    // Permission are not checked in this submodule, see 'View site reports' permission.
    $html = $this
      ->getHeaders($name, $this
      ->getDebugInformation()) . $this
      ->getDebug($var);

    // Locale issue https://www.drupal.org/project/drupal/issues/1885192:
    // field locales_source.source is not suitable for long texts and huge config objects.
    if (\Drupal::moduleHandler()
      ->moduleExists('locale') && ($length = mb_strlen($html) >= 64000)) {
      \Drupal::logger('vardumper_watchdog')
        ->debug('Cannot log objects longer than 64Kb if Locale module is enabled. Currents size is @size. See <a href=https://www.drupal.org/project/drup al/issues/1885192>https://www.drupal.org/project/drupal/issues/1885192</a>. @excerpt...', [
        '@size' => $length,
        '@excerpt' => mb_substr(strip_tags($html), 0, 256),
      ]);
    }
    else {
      \Drupal::logger('vardumper_watchdog')
        ->debug($html);
    }
  }

}

Classes

Namesort descending Description
VarDumperWatchdog The VarDumperWatchdog class.