Skip to content

Commit a7df1e3

Browse files
committed
Add Laravel 6 support
1 parent c49405e commit a7df1e3

File tree

8 files changed

+25
-45
lines changed

8 files changed

+25
-45
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 7.1
54
- 7.2
65
- 7.3
76

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Logging and notifications for Laravel console commands.
1515

1616
| Laravel | Console Logger |
1717
| ------- | :-----------------------------------------------------------------------: |
18+
| 6.x | [6.x](https://github.com/dmitry-ivanov/laravel-console-logger/tree/6.x) |
1819
| 5.8.* | [5.8.*](https://github.com/dmitry-ivanov/laravel-console-logger/tree/5.8) |
1920
| 5.7.* | [5.7.*](https://github.com/dmitry-ivanov/laravel-console-logger/tree/5.7) |
2021
| 5.6.* | [5.6.*](https://github.com/dmitry-ivanov/laravel-console-logger/tree/5.6) |

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
"email": "[email protected]"
1313
}],
1414
"require": {
15-
"php": "^7.1.3",
16-
"illuminate/support": "5.8.*",
17-
"illuminate/console": "5.8.*",
18-
"illuminated/helper-functions": "5.8.*",
19-
"monolog/monolog": "^1.12",
15+
"php": "^7.2",
16+
"illuminate/support": "^6.0",
17+
"illuminate/console": "^6.0",
18+
"illuminated/helper-functions": "^6.0",
19+
"monolog/monolog": "^1.12|^2.0",
2020
"psr/http-message": "^1.0",
2121
"psr/log": "^1.0",
22-
"symfony/finder": "^4.2"
22+
"symfony/finder": "^4.3"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^7.5|^8.0",
26-
"mockery/mockery": "^1.0",
25+
"phpunit/phpunit": "^8.3",
26+
"mockery/mockery": "^1.2",
2727
"guzzlehttp/guzzle": "^6.3",
28-
"orchestra/testbench": "3.8.*",
29-
"illuminated/testing-tools": "5.8.*"
28+
"orchestra/testbench": "^4.0",
29+
"illuminated/testing-tools": "^6.0"
3030
},
3131
"autoload": {
3232
"files": [

src/Loggable/FileChannel/MonologFormatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class MonologFormatter extends LineFormatter
99
{
1010
public function __construct()
1111
{
12-
parent::__construct("[%datetime%]: [%level_name%]: %message%\n%context%\n", null, true, true);
12+
parent::__construct("[%datetime%]: [%level_name%]: %message%\n%context%\n", 'Y-m-d H:i:s', true, true);
1313
}
1414

15-
public function format(array $record)
15+
public function format(array $record): string
1616
{
1717
if ($record['message'] == '%separator%') {
1818
return str_repeat("\n", 11);
@@ -22,7 +22,7 @@ public function format(array $record)
2222
return rtrim($output) . "\n";
2323
}
2424

25-
protected function convertToString($data)
25+
protected function convertToString($data): string
2626
{
2727
if (is_array($data)) {
2828
return get_dump($data);

src/Loggable/Notifications/DatabaseChannel/MonologDatabaseHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ protected function guaranteeTableExists()
4141
});
4242
}
4343

44-
protected function write(array $record)
44+
protected function write(array $record): void
4545
{
4646
if (!empty($this->callback)) {
47-
return call_user_func($this->callback, $record);
47+
call_user_func($this->callback, $record);
48+
return;
4849
}
4950

5051
$now = Carbon::now();

src/Loggable/Notifications/EmailChannel/EmailChannel.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminated\Console\Loggable\Notifications\EmailChannel;
44

55
use Monolog\Logger;
6-
use Monolog\Handler\MandrillHandler;
76
use Monolog\Handler\SwiftMailerHandler;
87
use Monolog\Handler\NativeMailerHandler;
98
use Monolog\Handler\DeduplicationHandler;
@@ -34,20 +33,14 @@ protected function getEmailChannelHandler()
3433
case 'mail':
3534
case 'smtp':
3635
case 'sendmail':
37-
case 'mandrill':
3836
$mailer = app('swift.mailer');
3937
$message = $mailer->createMessage();
4038
$message->setSubject($subject);
4139
$message->setFrom(to_swiftmailer_emails($from));
4240
$message->setTo(to_swiftmailer_emails($recipients));
4341
$message->setContentType('text/html');
4442
$message->setCharset('utf-8');
45-
46-
if ($driver == 'mandrill') {
47-
$mailerHandler = new MandrillHandler(config('services.mandrill.secret'), $message, $level);
48-
} else {
49-
$mailerHandler = new SwiftMailerHandler($mailer, $message, $level);
50-
}
43+
$mailerHandler = new SwiftMailerHandler($mailer, $message, $level);
5144
break;
5245

5346
default:

src/Loggable/Notifications/EmailChannel/MonologHtmlFormatter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
class MonologHtmlFormatter extends HtmlFormatter
88
{
9-
public function format(array $record)
9+
public function __construct()
10+
{
11+
parent::__construct('Y-m-d H:i:s');
12+
}
13+
14+
public function format(array $record): string
1015
{
1116
$output = '<!DOCTYPE html>';
1217
$output .= '<html>';
@@ -118,7 +123,7 @@ protected function composeRow($header, $body = ' ')
118123
</tr>";
119124
}
120125

121-
protected function convertToString($data)
126+
protected function convertToString($data): string
122127
{
123128
if (is_array($data)) {
124129
return get_dump($data);

tests/Loggable/Notifications/EmailChannel/EmailChannelTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminated\Console\Tests\Loggable\Notifications\EmailChannel;
44

55
use Monolog\Logger;
6-
use Monolog\Handler\MandrillHandler;
76
use Illuminated\Console\Tests\TestCase;
87
use Monolog\Handler\SwiftMailerHandler;
98
use Monolog\Handler\NativeMailerHandler;
@@ -59,15 +58,6 @@ public function it_uses_configured_monolog_swift_mailer_handler_on_sendmail_driv
5958
$this->assertMailerHandlersEqual($this->composeSwiftMailerHandler(), $handler);
6059
}
6160

62-
/** @test */
63-
public function it_uses_configured_monolog_mandrill_mailer_handler_on_mandrill_driver()
64-
{
65-
config(['mail.driver' => 'mandrill', 'services.mandrill.secret' => 'secret']);
66-
$handler = $this->runArtisan(new EmailNotificationsCommand)->emailChannelHandler();
67-
68-
$this->assertMailerHandlersEqual($this->composeMandrillMailerHandler(), $handler);
69-
}
70-
7161
/** @test */
7262
public function it_uses_configured_monolog_native_mailer_handler_on_other_drivers()
7363
{
@@ -94,15 +84,6 @@ private function composeSwiftMailerHandler()
9484
return $handler;
9585
}
9686

97-
private function composeMandrillMailerHandler()
98-
{
99-
$handler = new MandrillHandler(
100-
config('services.mandrill.secret'), $this->composeMailerHandlerMessage(), Logger::NOTICE
101-
);
102-
$handler->setFormatter(new MonologHtmlFormatter);
103-
return $handler;
104-
}
105-
10687
private function composeNativeMailerHandler($name = 'email-notifications-command')
10788
{
10889
$handler = new NativeMailerHandler(

0 commit comments

Comments
 (0)