October 2017
Intermediate to advanced
566 pages
14h 31m
English
Now that we have a channel for our module, let's assume that we want to also 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 LoggerInterface implementation, which typically goes in the Logger folder of our namespace. So, let's call ours MailLogger; the following is the code for it:
namespace Drupal\hello_world\Logger;use Drupal\Core\Logger\RfcLoggerTrait;use Psr\Log\LoggerInterface;/** * A logger that sends an email ...
Read now
Unlock full access