March 2019
Intermediate to advanced
580 pages
15h 3m
English
Now that we have a channel for our module, let's assume that we also want to log messages elsewhere. They are fine to be stored in the database, but let's also send an email whenever we encounter an error log. In this section, we will only cover the logging architecture needed for this and defer the actual mailing implementation to the second part of this chapter when we discuss mailing.
The first thing that we will need to create is the LoggerInterface implementation, which typically goes in the Logger folder of our namespace. So, let's call ours MailLogger. And it can look like this:
namespace Drupal\hello_world\Logger;use Drupal\Core\Logger\RfcLoggerTrait;use Psr\Log\LoggerInterface;/** * A logger that sends an email when ...
Read now
Unlock full access