Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 4079084

Browse files
committed
Monolog2 upgrade
1 parent 77e7ca3 commit 4079084

File tree

6 files changed

+31
-25
lines changed

6 files changed

+31
-25
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
7-
- hhvm
4+
- 7.2
5+
- 7.3
6+
- 7.4
7+
- 8.0
88
- nightly
99

1010
before_script:

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.0.0 - 2020-09-03
4+
5+
* Monolog2 support
6+
37
## 1.0.0 - 2016-04-04
48

5-
* Initial release
9+
* Initial release

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=5.4.0",
13-
"monolog/monolog": "~1.0"
12+
"php": ">=7.2",
13+
"monolog/monolog": "~2.0"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "~5.0"
16+
"phpunit/phpunit": "^8.5|^9"
1717
},
1818
"autoload": {
1919
"psr-4": {
@@ -22,7 +22,7 @@
2222
},
2323
"extra": {
2424
"branch-alias": {
25-
"dev-master": "1.0-dev"
25+
"dev-master": "2.0-dev"
2626
}
2727
}
2828
}

src/GoogleCloudJsonFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class GoogleCloudJsonFormatter extends JsonFormatter
99
/**
1010
* {@inheritdoc}
1111
*/
12-
public function format(array $record)
12+
public function format(array $record): string
1313
{
1414
return json_encode(
1515
$this->translateRecordForGoogleCloudLoggingFormat($record)
@@ -23,7 +23,7 @@ public function format(array $record)
2323
*
2424
* @return string
2525
*/
26-
protected function formatBatchJson(array $records)
26+
protected function formatBatchJson(array $records): string
2727
{
2828
$records = array_map(
2929
function ($record) {

tests/GoogleCloudJsonFormatterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

33
use Monolog\Logger;
4+
use PHPUnit\Framework\TestCase;
45
use Superbalist\Monolog\Formatter\GoogleCloudJsonFormatter;
56

6-
class GoogleCloudJsonFormatterTest extends PHPUnit_Framework_TestCase
7+
class GoogleCloudJsonFormatterTest extends TestCase
78
{
89
/**
910
* @test

tests/GoogleCloudLoggerTest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
use Monolog\Handler\StreamHandler;
44
use Monolog\Logger;
5+
use PHPUnit\Framework\TestCase;
56
use Superbalist\Monolog\Formatter\GoogleCloudJsonFormatter;
67

7-
class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
8+
class GoogleCloudLoggerTest extends TestCase
89
{
910
/**
1011
* @var Logger
@@ -15,15 +16,15 @@ class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
1516
/**
1617
* Setup before test runs
1718
*/
18-
public static function setUpBeforeClass()
19+
public static function setUpBeforeClass(): void
1920
{
2021
touch(static::$logfileOutput);
2122
}
2223

2324
/**
2425
* Test setup
2526
*/
26-
public function setUp()
27+
public function setUp(): void
2728
{
2829
$handler = new StreamHandler(static::$logfileOutput, Logger::DEBUG);
2930
$handler->setFormatter(new GoogleCloudJsonFormatter());
@@ -34,7 +35,7 @@ public function setUp()
3435
/**
3536
* Cleanup
3637
*/
37-
public function tearDown()
38+
public function tearDown(): void
3839
{
3940
file_put_contents(static::$logfileOutput, '');
4041
unset($this->log);
@@ -43,7 +44,7 @@ public function tearDown()
4344
/**
4445
* Cleanup after all tests ran
4546
*/
46-
public static function tearDownAfterClass()
47+
public static function tearDownAfterClass(): void
4748
{
4849
unlink(static::$logfileOutput);
4950
}
@@ -55,7 +56,7 @@ public function it_should_log_a_debug_in_the_expected_format()
5556
{
5657
$dt = $this->getDateTimeforTest();
5758

58-
$this->log->addDebug('Test Debug Occurred');
59+
$this->log->debug('Test Debug Occurred');
5960

6061
$expected = '{"message":"Test Debug Occurred","severity":"DEBUG","timestamp":{"seconds":'
6162
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -70,7 +71,7 @@ public function it_should_log_an_info_in_the_expected_format()
7071
{
7172
$dt = $this->getDateTimeforTest();
7273

73-
$this->log->addInfo('Test Info Occurred');
74+
$this->log->info('Test Info Occurred');
7475

7576
$expected = '{"message":"Test Info Occurred","severity":"INFO","timestamp":{"seconds":'
7677
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -85,7 +86,7 @@ public function it_should_log_a_notice_in_the_expected_format()
8586
{
8687
$dt = $this->getDateTimeforTest();
8788

88-
$this->log->addNotice('Test Notice Occurred');
89+
$this->log->notice('Test Notice Occurred');
8990

9091
$expected = '{"message":"Test Notice Occurred","severity":"NOTICE","timestamp":{"seconds":'
9192
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -100,7 +101,7 @@ public function it_should_log_a_warning_in_the_expected_format()
100101
{
101102
$dt = $this->getDateTimeforTest();
102103

103-
$this->log->addWarning('Test Warning Occurred');
104+
$this->log->warning('Test Warning Occurred');
104105

105106
$expected = '{"message":"Test Warning Occurred","severity":"WARNING","timestamp":{"seconds":'
106107
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -115,7 +116,7 @@ public function it_should_log_an_error_in_the_expected_format()
115116
{
116117
$dt = $this->getDateTimeforTest();
117118

118-
$this->log->addError('Test Error Occurred');
119+
$this->log->error('Test Error Occurred');
119120

120121
$expected = '{"message":"Test Error Occurred","severity":"ERROR","timestamp":{"seconds":' . $dt->getTimestamp()
121122
. ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -130,7 +131,7 @@ public function it_should_log_a_critical_in_the_expected_format()
130131
{
131132
$dt = $this->getDateTimeforTest();
132133

133-
$this->log->addCritical('Test Critical Occurred');
134+
$this->log->critical('Test Critical Occurred');
134135

135136
$expected = '{"message":"Test Critical Occurred","severity":"CRITICAL","timestamp":{"seconds":'
136137
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -145,7 +146,7 @@ public function it_should_log_an_alert_in_the_expected_format()
145146
{
146147
$dt = $this->getDateTimeforTest();
147148

148-
$this->log->addAlert('Test Alert Occurred');
149+
$this->log->alert('Test Alert Occurred');
149150

150151
$expected = '{"message":"Test Alert Occurred","severity":"ALERT","timestamp":{"seconds":'
151152
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";
@@ -160,7 +161,7 @@ public function it_should_log_an_emergency_in_the_expected_format()
160161
{
161162
$dt = $this->getDateTimeforTest();
162163

163-
$this->log->addEmergency('Test Emergency Occurred');
164+
$this->log->emergency('Test Emergency Occurred');
164165

165166
$expected = '{"message":"Test Emergency Occurred","severity":"EMERGENCY","timestamp":{"seconds":'
166167
. $dt->getTimestamp() . ',"nanos":0},"channel":"test-channel"}' . "\n";

0 commit comments

Comments
 (0)