- Issue created by @Jons
- 🇳🇱Netherlands J V
While Kint can create plain text dumps, Devel doesn't pass any information about the format of the dump to the dumper plugin. I could make a hacky workaround to see if specific functions like ddm are in the stack trace but I'd rather not. Other dumpers like symfony/var-dumper also leave JS/CSS in the log file.
You could make the log file an html file so it opens in a browser rather than a text editor if you want to see the output correctly.
If devel had an option to choose a separate dumper for log files and normal dumps you could just configure it at will but that's a feature request for devel, not kint.
I plan to start work on the next kint release in a week. If I have time afterwards I might add a hack for ddm but I will probably just close this issue
- 🇬🇧United Kingdom Jons
It is quite important, esp for non-UI modules.
Something like this was seen before and the following patch fixed it---- a/src/Plugin/Devel/Dumper/VarDumper.php -+++ b/src/Plugin/Devel/Dumper/VarDumper.php @@ -24,7 +24,7 @@ */ public function export(mixed $input, ?string $name = NULL): MarkupInterface|string { $cloner = new VarCloner(); - $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper(); + $dumper = new CliDumper(); $output = fopen('php://memory', 'r+b'); $dumper->dump($cloner->cloneVar($input), $output); @@ -34,7 +34,7 @@ $output = $name . ' => ' . $output; } - return $this->setSafeMarkup($output); + return $output; } /** --- a/src/DevelDumperManager.php +++ b/src/DevelDumperManager.php @@ -135,7 +135,7 @@ * {@inheritdoc} */ public function debug($input, $name = NULL, $plugin_id = NULL) { - $output = $this->createInstance($plugin_id)->export($input, $name) . "\n"; + $output = $this->createInstance($plugin_id)->export($input, $name); // The temp directory does vary across multiple simpletest instances. $file = $this->config->get('debug_logfile'); if (empty($file)) {
Not sure how to reapply to export()
- 🇬🇧United Kingdom Jons
As an initial hack - this seems to work for log and does not break UI.
--- a/DevelDumperManager_1 +++ b/DevelDumperManager @@ -135,7 +135,7 @@ * {@inheritdoc} */ public function debug($input, ?string $name = NULL, ?string $plugin_id = NULL) { + $output = $name . ': ' . print_r($input, TRUE) . "\n"; - $output = $this->createInstance($plugin_id)->export($input, $name) . "\n"; // The temp directory does vary across multiple simpletest instances. $file = $this->config->get('debug_logfile');
- 🇳🇱Netherlands J V
As an initial hack - this seems to work for log and does not break UI.
Looking at DevelDumperManagerInterface your hack might actually be close to correct. While you can set the dump file to whatever extension you want it was clearly intended to be text based on the docblock:
Logs a variable to a drupal_debug.txt in the site's temp directory.
Anyway, regardless of whether it needs to be text or have a separate dumper configured that's not a change to kint, that's a change to devel. Your hack doesn't even touch a file in kint. Either decorate devel's dumper manager or ask them for the feature.
Closing this since it's out of scope
- 🇬🇧United Kingdom Jons