Check Log messages for errors
LSM team enables DB log while doing testing and builds on Tugboat. We first clear the logs, run our tests, then check the logs for any errors and report back as failed if there are any.
If we want to do this in a way that doesn't require dblogging that's totally an option. Right now we're accomplishing this using our e2e tests.
@mrdavidburns: what is your idea? A workflow? A PR check from Tugboat?
We first clear the logs, run our tests, then check the logs for any errors and report back as failed if there are any.
If we need to run our tests, then Drainpipe needs to know we ran our tests. Is that possible with Dranipipe?
Doing this with the DDEV Playwright add-on might be a better solution. similarly do what has been done here: https://github.com/Lullabot/playwright-drupal/blob/main/src/testcase/test.ts#L65-L73
Can we think of a time/place when using Drainpipe that it would make sense to execute this check?
Instead of doing this w/ Playwright (or Nightwatch or Cypress) we just use the ddev logs functionality. This should work on any project that is using Drainpipe.
Have this command run at the end of ddev task test:functional output all errors to an artifact. Only fail task on fatal error, but always append the full output of warnings, notices, and errors regardless of pass or fail.
Leave it up to whatever e2e test runner to implement their own log tester however they want. Like checking logs after each individual test is run.
@mrdavidburns I was reviewing the ddev logs command documentation and testing it, but the logs that return are related to the ddev services but not to the PHP errors or dblog.
@alexanderpatriciop have you tried including the specific service that you're looking to get the logs from?
I see there's a --service flag where you can define db or web. I would think the web one would include the logs from php-fpm or nginx, but maybe that's not actually giving us the PHP logs which is what we would want in this instance.
see: https://ddev.readthedocs.io/en/stable/users/usage/commands/#logs
PHP errors and exceptions that are not caught should be logged by default. You can double check by sticking a call to error_log() in index.php. For Drupal logs, you need to redirect logs to stderr which is best done with monolog with something like this:
parameters:
monolog.channel_handlers:
default:
handlers:
- name: 'error_log'
formatter: 'drush'
This has me thinking that this may be difficult to do in a way that works on all sites. Some sites may be using the database logs, some may not, some may have monolog configured to save to a separate file instead of stderr, etc.
Thanks for that info @deviantintegral I was searching around yesterday for more information about this without much success.
This has me thinking that this may be difficult to do in a way that works on all sites. Some sites may be using the database logs, some may not, some may have monolog configured to save to a separate file instead of stderr, etc.
Would it be possible to have Drainpipe scaffold some DDEV configuration so that most/all projects using Drainpipe are configured the same (or as close as we can get) so that doing this with a DDEV command is possible?