LogDriver should work in debug mode

This commit is contained in:
Alexander Skvortsov 2022-01-05 21:47:33 -05:00
parent 52896144e1
commit ae5bfcc7ec
2 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace Flarum\Mail;
use Illuminate\Mail\Transport\LogTransport;
use Psr\Log\LoggerInterface;
use Swift_Mime_SimpleMessage;
use Swift_Mime_SimpleMimeEntity;
class FlarumLogTransport extends LogTransport
{
/**
* {@inheritdoc}
*
* @return int
*/
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
// Overriden to use info, so the log driver works in non-debug mode.
$this->logger->info($this->getMimeEntityString($message));
$this->sendPerformed($message);
return $this->numberOfRecipients($message);
}
}

View File

@ -11,7 +11,6 @@ namespace Flarum\Mail;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Mail\Transport\LogTransport;
use Illuminate\Support\MessageBag;
use Psr\Log\LoggerInterface;
use Swift_Transport;
@ -45,6 +44,6 @@ class LogDriver implements DriverInterface
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
{
return new LogTransport($this->logger);
return new FlarumLogTransport($this->logger);
}
}