Problem/Motivation

Sometimes it is useful to get all the debugging information this module provides, but sometimes I want to debug the processing of just one field. This module gives me too much information (all the other fields) and not enough (only the source values for the process pipeline).

I sometimes want to see what is happening during each step in the process pipeline for a single field.

Proposed resolution

Add a debug process plugin, similar to the log plugin provided by core. Instead of saving messages, show them with print_r(). Then I can debug my process pipelines by adding

-
  plugin: debug

as needed.

This has a few advantages over using the core log plugin:

  • Using print_r() handles both arrays and strings gracefully.
  • It is easier to distinguish debugging code that should be removed from logging code that should stay.
  • It saves a step: no need to use drush mmsg my_migration to see the messages.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Assigned: benjifisher » Unassigned
Status: Active » Needs review
StatusFileSize
new3.22 KB

Here is a patch with the plugin I have been using. I just added the multiple option and have not tested it, yet.

selwynpolit’s picture

@benjifisher, this seems like a very useful plugin. I noticed one small issue. The namespace line should be:

namespace Drupal\migrate_devel\Plugin\migrate\process;

Also I found it useful to add a little more to the output so the person using the plugin could clearly identify the "debug output: "

  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    print("debug output: ");
    print_r($value);
    if (!is_array($value)) {
      print_r(PHP_EOL);
    }

    return $value;
  }
selwynpolit’s picture

Status: Needs review » Needs work
benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB
new3.54 KB

@selwynpolit:

Oops, thanks for catching the namespace problem.

Good idea for adding a label. Let's make it more flexible by adding a new (optional) label parameter. Then you can leave it off if you do not care, or distinguish between different steps in the pipeline (if you are adding the debug plugin in more than one place).

I have attached an updated patch.

selwynpolit’s picture

@benjifisher That works great. I like the customizable label option.

selwynpolit’s picture

Status: Needs review » Reviewed & tested by the community

  • Derimagia committed 4984acb on 8.x-1.x authored by benjifisher
    Issue #3021648 by benjifisher, selwynpolit: Add a migrate plugin to...
Derimagia’s picture

Status: Reviewed & tested by the community » Fixed

Thanks - Sorry for the delay, commited

benjifisher’s picture

@Derimagia:

No worries. Thanks for the module!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.