Integration between Tracy and Nette/IMailer

3 months ago

2bfree
Member | 245
+
0
-

The server we are run our application on does not support native php mail() function.
We are using the Nette\SmtpMailer instead.

Current version of Tracy does not support using mail.mailer service.

Is there any way to force Tracy to send email via this service?

3 months ago

Jan Tvrdík
Nette guru | 2489
+
+1
-

You can set Tracy\Debugger()::getLogger()->mailer to callback of your choice. No built-in integration between Tracy and Nette\Mail is AFAIK currently available.

3 months ago

2bfree
Member | 245
+
+2
-

Current hotfix solution we used is

Tracy\Mailer.php

services:
    tracyMailer:
        class: Tracy\Mailer

    tracy.logger:
        factory: Tracy\Debugger::getLogger()
        setup:
            - $mailer([@tracyMailer, 'send'])

thanks for help.

Last edited by 2bfree (2017-01-04 10:13)

3 months ago

Jan Tvrdík
Nette guru | 2489
+
0
-

cc @DavidGrudl How do you feel about adding this bridge to Tracy?


@2bfree Does it work without the factory: line?

3 months ago

2bfree
Member | 245
+
0
-

The factory line is copy of the native tracy.logger service definition from the native DI extension.

As I understand the Neon DI definition, there is no way to overwrite definition of the service by just adding the setup. I thing that you can overwrite all or nothing and there is no way to define the service without class, factory or implement definition? Or am I wrong?

3 months ago

Jan Tvrdík
Nette guru | 2489
+
+1
-

@2bfree So, have you actually tried it without the factory: line? Or do you just believe that it will not work?

If it does not work, we should look into making it work. The first thing you can try is to remove the condition on lines 91 and 93 in TracyExtension, so the code look like this.

$logger = $builder->getDefinition($this->prefix('logger'));
$initialize->addBody($builder->formatPhp('Tracy\Debugger::setLogger(?);', [$logger]));

3 months ago

2bfree
Member | 245
+
0
-

Actually colleague tried it without factory and It works! :) Interesting :)

3 months ago

David Grudl
founder | 6644
+
0
-

Jan Tvrdík wrote:

cc @DavidGrudl How do you feel about adding this bridge to Tracy?

How should it look like?

3 months ago

Jan Tvrdík
Nette guru | 2489
+
0
-

@DavidGrudl Sth like https://gist.github.com/…e2c43e2c9ce5, but with less code duplication, i.e. class accepting IMailer in constructor and providing (with method or __invoke) the callback required by Tracy.

3 months ago

David Grudl
founder | 6644
+
+2
-

That could be useful.

Board footer

Terms and conditions