Created
April 22, 2016 03:20
-
-
Save oprudkyi/afd69bced08412f59e220ceedb5d3e82 to your computer and use it in GitHub Desktop.
laravel swift mailer logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use Swift_Mailer; | |
use \Swift_Plugins_Logger; | |
use \Swift_Plugins_LoggerPlugin; | |
class DebugMailServiceProvider extends ServiceProvider implements Swift_Plugins_Logger | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
// | |
} | |
/** | |
* Register the application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
if(env('SWIFT_MAIL_LOG', false)) { | |
$this->app->resolving('swift.mailer', function (Swift_Mailer $mailer, $app) { | |
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this)); | |
}); | |
} | |
} | |
/** | |
* Add a log entry. | |
* | |
* @param string $entry | |
*/ | |
public function add($entry) | |
{ | |
\Log::info($entry); | |
} | |
/** | |
* Not implemented. | |
*/ | |
public function clear() | |
{ | |
} | |
/** | |
* Not implemented. | |
*/ | |
public function dump() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment