When building and maintaining ECA models, testing if they really work as expected can be tricky because everything is supposed to be processed in the background. While programmers could easily switch over to use XDebug to find out why the processing doesn't work as expected, site builders won't ever consider doing that.
Therefore, ECA provides two options for debugging its processes right in the UI:
- Simple mode: Drupal core's database logging
- Expert mode: Webprofiler
Both options are easy to use and all steps required are described below.
Simple mode: Drupal core's database logging¶
- Enable the "Database Logging" (
- Go to Administration / Configuration / Workflow / ECA / Settings (
/admin/config/workflow/eca/settings) and select the log level
debugto see all the details about what ECA is processing and why
That's it. ECA will write comprehensive details about every single step to the database log of your Drupal site. While reviewing that information in the default log interface, ECA provides its own log review UI which only contains ECA related records:
Go to Administration / Configuration / Workflow / ECA / Log (
/admin/config/workflow/eca/log) where you find the
list of all recent debugging messages:
This view provides the messages in chronological order. This is on purpose because each page request will add new debug messages and would they be shown at the top of the list, navigating through the pages would not really work out. However, if you don't like that, you can adjust the view ECA Log and e.g. change the sort order.
In the log view you can follow each step ECA has taken while processing each model. It shows the user account and the time, by whom and when the step was processed. And each message not only describes the step itself, it also contains the list of tokens with their name and value, which were known at the beginning of that particular step.
Knowing the tokens is very helpful
Most of the time, if an ECA model doesn't quite work as expected, the reason behind that is a missing token or the token is present but under a different name. This is why the ECA debugging options are so helpful. They tell you right away, what's missing.
This debugging option is fairly simple and may be difficult to use, at least when you're working with more complex and/or a number of models at the same time. On the other hand, it is easy to enable and afterwards disable again. Speaking of which: please don't forget to rest the ECA log level to something less verbose, otherwise the huge number of log messages from ECA could easily impact your site's performance.
Expert mode: Webprofiler¶
- For ECA 1:
- Install the "Webprofiler" module:
composer require drupal/webprofiler
- Enable the "Webprofiler" module
- For ECA 2:
- Install the "ECA Webprofiler" module:
composer require drupal/eca_webprofiler
- Enable the "ECA Webprofiler" module and its dependencies
- Go to Administration / Configuration / Development / Devel / Webprofiler (
/admin/config/development/devel/webprofiler) and enable the ECA toolbar item
The database logging module is not required when you're using the webprofiler as your debugging method. Also, there is no need to change the log level settings either. As soon as ECA is enabled as a toolbar item in the webprofiler settings, you will get its debugging functionality working for you.
From now on you'll see the webprofiler toolbar at the bottom of you screen with detailed information about the latest page request:
When you click on the ECA icon, the webprofiler opens a page with details ECA logging messages from just that single page request:
The messages contained here are the same as described above for the simple debugging mode. But the benefit of this professional debugging method is the isolation of debugging messages for each page request individually.