Skip to content

Commit 149f4b9

Browse files
committed
feat: rework of the package & Laravel 6 / 7 support
Thanks to @jbeales designmynight/laravel-log-mailer#7
1 parent bc712b9 commit 149f4b9

File tree

12 files changed

+241
-246
lines changed

12 files changed

+241
-246
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# Changelog
22

3-
All notable changes to `laravel-log-mailer` will be documented in this file
3+
All notable changes to `laravel-mail-log-channel` will be documented in this file
4+
5+
## 1.1.0 - 2020-01-29
6+
7+
- add support for Laravel 6 and 7 (thanks to @jbeales https://github.com/designmynight/laravel-log-mailer/pull/7)
8+
- remove extra configuration and view files
9+
- improve exception layout in mails
410

511
## 1.0.2 - 2018-09-09
12+
613
- fix logging levels
714

815
## 1.0.1 - 2018-09-05
16+
917
- fix dependancy
1018

1119
## 1.0.0 - 2018-09-04
12-
- initial release
20+
21+
- initial release

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
Laravel Mail Logger
22
===============
33

4-
[![Latest Stable Version](http://img.shields.io/github/release/designmynight/laravel-log-mailer.svg)](https://packagist.org/packages/designmynight/laravel-log-mailer) [![Total Downloads](http://img.shields.io/packagist/dm/designmynight/laravel-log-mailer.svg)](https://packagist.org/packages/designmynight/laravel-log-mailer)
4+
[![Latest Stable Version](http://img.shields.io/github/release/shaffe/laravel-mail-log-channel.svg)](https://packagist.org/packages/shaffe/laravel-mail-log-channel) [![Total Downloads](http://img.shields.io/packagist/dm/shaffe/laravel-mail-log-channel.svg)](https://packagist.org/packages/shaffe/laravel-mail-log-channel)
55
[![StyleCI](https://github.styleci.io/repos/147424037/shield?branch=master)](https://github.styleci.io/repos/147424037)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
A service provider to add support for logging via email using Laravels built-in mail provider
8+
A service provider to add support for logging via email using Laravels built-in mail provider.
9+
10+
This package is a fork of [laravel-log-mailer](https://packagist.org/packages/designmynight/laravel-log-mailer) by Steve Porter.
11+
12+
**This fork introduces some breaking changes. If you're upgrading from it, please follow the [configuration](#configuration) bellow.**
913

1014
![image](https://user-images.githubusercontent.com/12199424/45576336-a93c1300-b86e-11e8-9575-d1e4c5ed5dec.png)
1115

@@ -18,69 +22,76 @@ Table of contents
1822
Installation
1923
------------
2024

21-
Installation using composer:
25+
You can install this package via composer using this commande:
2226

2327
```sh
24-
composer require designmynight/laravel-log-mailer
28+
composer require shaffe/laravel-mail-log-channel
2529
```
2630

31+
2732
### Laravel version Compatibility
2833

2934
Laravel | Package |
3035
:---------|:--------|
36+
7.x | 2.0.x |
37+
6.x | 2.0.x |
3138
5.6.x | 1.0.x |
32-
33-
And add the service provider in `config/app.php`:
34-
35-
```php
36-
DesignMyNight\Laravel\Logging\MailableLogServiceProvider::class,
37-
```
39+
40+
The package will automatically register itself if you use Laravel.
3841

3942
For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`.
4043

4144
```php
42-
$app->register(DesignMyNight\Laravel\Logging\MailableLogServiceProvider::class);
45+
$app->register(Shaffe\MailLogChannel\MailLogChannelServiceProvider::class);
4346
```
4447

4548
Configuration
4649
------------
4750

48-
Most configuration options can be automatically populated by environment variables or in config/mailablelog.php, to generate it run php artisan vendor:publish.
51+
To ensure all unhandled exceptions are mailed:
4952

50-
To ensure all unhandled exceptions are mailed, set up a mail logging channel and add it to your logging stack in config/logging.php:
53+
1. create a `mail` logging channel in `config/logging.php`,
54+
2. add this `mail` channel to your current logging stack,
55+
3. add a `LOG_MAIL_ADDRESS` to your `.env` file to define the recipient.
5156

5257
```php
5358
'channels' => [
5459
'stack' => [
5560
'driver' => 'stack',
56-
// Add mail to the stack:
61+
// 2. Add mail to the stack:
5762
'channels' => ['single', 'mail'],
5863
],
5964

6065
// ...
6166

62-
// Create a mail logging channel:
67+
// 1. Create a mail logging channel:
6368
'mail' => [
6469
'driver' => 'mail',
70+
'level' => env('LOG_MAIL_LEVEL', 'notice'),
71+
6572
// Specify who to mail the log to
6673
'to' => [
6774
[
68-
'address' => 'errors@designmynight.com',
75+
'address' => env('LOG_MAIL_ADDRESS'),
6976
'name' => 'Error'
7077
]
7178
],
72-
// Optionally specify who the log mail was sent by
73-
// This is overidable in config/mailablelog.php and
74-
// falls back to your global from in config/mail.php
75-
'from' => [
76-
'address' => 'errors@designmynight.com',
77-
'name' => 'Errors'
78-
],
79+
80+
// Optionally overwrite the sender.
81+
// Default is config('mail.from.address') and config('mail.from.name')
82+
// 'from' => [
83+
// 'address' => env('LOG_MAIL_ADDRESS'),
84+
// 'name' => 'Errors'
85+
// ],
86+
87+
// Optionally overwrite the subject format pattern
88+
// 'subject_format' => env('LOG_MAIL_SUBJECT_FORMAT', '[%datetime%] %level_name%: %message%'),
89+
7990
// Optionally overwrite the mailable template
91+
// Two variables are sent to the view: `string $content` and `array $records`
8092
// 'mailable' => NewLogMailable::class
8193
],
8294
],
8395
```
8496

85-
You can specify multiple channels and change the recipients and customise the email template per channel.
86-
97+
You can specify multiple channels and change the recipients and customize the email template per channel.

composer.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
{
2-
"name": "designmynight/laravel-log-mailer",
2+
"name": "shaffe/laravel-mail-log-channel",
33
"description": "A package to support logging via email in Laravel",
4-
"homepage": "https://github.com/designmynight/laravel-log-mailer",
4+
"homepage": "https://github.com/shaffe-fr/laravel-mail-log-channel",
55
"license": "MIT",
66
"keywords": [
77
"laravel",
8-
"laravel-logging",
8+
"logging",
9+
"mail channel",
910
"laravel-log-mailer",
1011
"monolog",
11-
"designmynight"
12+
"laravel-mail-log-channel",
13+
"shaffe"
1214
],
1315
"require": {
14-
"illuminate/support": "^5.6"
16+
"illuminate/bus": "^5.6|^6.0|^7.0",
17+
"illuminate/contracts": "^5.6|^6.0|^7.0",
18+
"illuminate/log": "^5.6|^6.0|^7.0",
19+
"illuminate/mail": "^5.6|^6.0|^7.0",
20+
"illuminate/queue": "^5.6|^6.0|^7.0",
21+
"illuminate/support": "^5.6|^6.0|^7.0"
1522
},
1623
"autoload": {
1724
"psr-4": {
18-
"DesignMyNight\\Laravel\\": "src"
25+
"Shaffe\\MailLogChannel\\": "src"
1926
}
2027
},
2128
"authors": [
29+
{
30+
"name": "Karel FAILLE",
31+
"email": "shaffe.fr@gmail.com",
32+
"role": "Developer"
33+
},
2234
{
2335
"name": "Steve Porter",
2436
"email": "steve@designmynight.com",
@@ -28,7 +40,7 @@
2840
"extra": {
2941
"laravel": {
3042
"providers": [
31-
"DesignMyNight\\Laravel\\Logging\\MailableLogServiceProvider"
43+
"Shaffe\\MailLogChannel\\MailLogChannelServiceProvider"
3244
]
3345
}
3446
}

config/mailablelog.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

resources/views/log.blade.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Logging/MailableLogServiceProvider.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/Logging/Monolog/Handlers/MailableHandler.php

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3-
namespace DesignMyNight\Laravel\Logging\Mail;
3+
namespace Shaffe\MailLogChannel\Mail;
44

55
use Illuminate\Bus\Queueable;
66
use Illuminate\Mail\Mailable;
77
use Illuminate\Queue\SerializesModels;
8+
use Illuminate\Support\HtmlString;
89

910
class Log extends Mailable
1011
{
@@ -17,6 +18,6 @@ class Log extends Mailable
1718
*/
1819
public function build()
1920
{
20-
return $this->markdown('mailablelog::log');
21+
return $this->markdown('mail::message', ['slot' => new HtmlString($this->viewData['content'] ?? '')]);
2122
}
2223
}

0 commit comments

Comments
 (0)