Last active
May 18, 2016 13:18
-
-
Save wallacemaxters/75037a613db19f656149b0fc6045a6cc to your computer and use it in GitHub Desktop.
Sistema de envio de relatório/log de erro com e-mail no Laravel 4
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 | |
// Substituir `App::error` pelo código abaixo: | |
App::error(function (Exception $exception, $code) { | |
// Se a aplicação estiver no "local" ou erro for "página não encontrada", não envia | |
if ($code === 404 || App::isLocal()) return; | |
//Log::error($exception); | |
Mail::send('emails.log_email', compact('exception', 'code'), function ($message) | |
{ | |
$message->to('destinatario'); | |
$message->subject('Laravel 4 - Log de erro'); | |
}); | |
}); |
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
<!-- colocar essa view na pasta emails --> | |
<body style="margin:0;padding:0;font-family: 'Courier New', Consolas, Tahoma, Arial;"> | |
<div style="margin:10px auto;padding:5px;width:900px;padding:5px;background-color:#fefefe"> | |
<h1 style="color: #444;border-bottom:1px solid #888;"> | |
<span style="color: #049">Nome do sistema</span> - Relatório de erro do sistema | |
</h1> | |
<h2 style="color:#049;">Status {{ $code }}</h2> | |
<div style="font-size: 16px"> | |
<h3>Mensagem de erro</h3> | |
<pre>{{ $exception->getMessage() }}</pre> | |
<h3>Tipo de Exceção</h3> | |
<pre>{{ get_class($exception) }}</pre> | |
<h3>BackTrace</h3> | |
<pre style="padding:10px;font-size:11px;overflow-x: auto;overflow-y:hidden;color: white;background-color:#142">{{ $exception}}</pre> | |
<h3>IP(s)</h3> | |
<pre style="color: #049">{{ HTML::ul(Request::ips()) }}</pre> | |
<h3>URL</h3> | |
<div> | |
<a href="{{ URL::current() }}" style="color:#346;text-decoration: none;font-weight: bold"> | |
{{ Str::title(Request::path()) }} | |
</a> | |
</div> | |
<h3>Método</h3> | |
<div style="color: #049;font-weight: bold">{{ Request::method() }}</div> | |
<h3>Parâmetros</h3> | |
<pre style="color: #049">{{ json_encode(Input::all(), JSON_PRETTY_PRINT) }}</pre> | |
@if(Auth::check()) | |
<h3>Usuário</h3> | |
<pre style="color: #049">{{ | |
json_encode(Auth::user()->getAttributes(), JSON_PRETTY_PRINT) | |
}} | |
</pre> | |
<h3>Nível do usuário</h3> | |
{{-- Deixei comentado, pois o seu sistema pode ser diferente o nome do nível do usuário --}} | |
<pre>{{-- Auth::user()->nivel->titulo --}}</pre> | |
@endif | |
</div> | |
<div style="padding:20px;color:#333;text-align: right;font-size:16x;font-weight: bold"> | |
{{ Carbon\Carbon::now()->formatLocalized('%d de %B de %Y às %H:%M:%S') }} | |
</div> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment