Feature: Change Log Target In Module

The company has several developers, each doing a separate module.

In production environment, if script throws exception, need sending email.

I want send letter with error on two emails: team-lead email and developer(s) email of module.

Developer (s) set them email in module property.

In the config file, you can specify only fixed emails, where you can send letters.

I want to set emails in module(in method init()).

How can I do it?

denisOgr, I think you need to investigate how to reconfigure the logging route on the fly, which I think is doable.

I’d try to do the following in the module’s init() method:

  1. unset the logging component

  2. get the config for the logging component, change it to your needs (add emails)

  3. set the logging component

For 1 and 3, I think you’ll have to work with the container of the application that, for example, Instance::ensure uses by default.

The approach I suggest, however, might break the logging, as it will reinit the logging component - you might have to deal with uniting two logging sessions as one. Or you might not.

Another (simpler) approach would be to ensure that you have the module’s alias already defined, and loop through that aliases + certain path that holds the email configuration. If module has email config file - emails are added to the config when application’s configuration file is processed.