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

Commit

Permalink
Monolog2 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoba committed Sep 3, 2020
1 parent 77e7ca3 commit 4079084
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- hhvm
- 7.2
- 7.3
- 7.4
- 8.0
- nightly

before_script:
Expand Down
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.0 - 2020-09-03

* Monolog2 support

## 1.0.0 - 2016-04-04

* Initial release
* Initial release
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
}
],
"require": {
"php": ">=5.4.0",
"monolog/monolog": "~1.0"
"php": ">=7.2",
"monolog/monolog": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "~5.0"
"phpunit/phpunit": "^8.5|^9"
},
"autoload": {
"psr-4": {
Expand All @@ -22,7 +22,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.0-dev"
}
}
}
4 changes: 2 additions & 2 deletions src/GoogleCloudJsonFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GoogleCloudJsonFormatter extends JsonFormatter
/**
* {@inheritdoc}
*/
public function format(array $record)
public function format(array $record): string
{
return json_encode(
$this->translateRecordForGoogleCloudLoggingFormat($record)
Expand All @@ -23,7 +23,7 @@ public function format(array $record)
*
* @return string
*/
protected function formatBatchJson(array $records)
protected function formatBatchJson(array $records): string
{
$records = array_map(
function ($record) {
Expand Down
3 changes: 2 additions & 1 deletion tests/GoogleCloudJsonFormatterTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Superbalist\Monolog\Formatter\GoogleCloudJsonFormatter;

class GoogleCloudJsonFormatterTest extends PHPUnit_Framework_TestCase
class GoogleCloudJsonFormatterTest extends TestCase
{
/**
* @test
Expand Down
27 changes: 14 additions & 13 deletions tests/GoogleCloudLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Superbalist\Monolog\Formatter\GoogleCloudJsonFormatter;

class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
class GoogleCloudLoggerTest extends TestCase
{
/**
* @var Logger
Expand All @@ -15,15 +16,15 @@ class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
/**
* Setup before test runs
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
touch(static::$logfileOutput);
}

/**
* Test setup
*/
public function setUp()
public function setUp(): void
{
$handler = new StreamHandler(static::$logfileOutput, Logger::DEBUG);
$handler->setFormatter(new GoogleCloudJsonFormatter());
Expand All @@ -34,7 +35,7 @@ public function setUp()
/**
* Cleanup
*/
public function tearDown()
public function tearDown(): void
{
file_put_contents(static::$logfileOutput, '');
unset($this->log);
Expand All @@ -43,7 +44,7 @@ public function tearDown()
/**
* Cleanup after all tests ran
*/
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
unlink(static::$logfileOutput);
}
Expand All @@ -55,7 +56,7 @@ public function it_should_log_a_debug_in_the_expected_format()
{
$dt = $this->getDateTimeforTest();

$this->log->addDebug('Test Debug Occurred');
$this->log->debug('Test Debug Occurred');

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

$this->log->addInfo('Test Info Occurred');
$this->log->info('Test Info Occurred');

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

$this->log->addNotice('Test Notice Occurred');
$this->log->notice('Test Notice Occurred');

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

$this->log->addWarning('Test Warning Occurred');
$this->log->warning('Test Warning Occurred');

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

$this->log->addError('Test Error Occurred');
$this->log->error('Test Error Occurred');

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

$this->log->addCritical('Test Critical Occurred');
$this->log->critical('Test Critical Occurred');

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

$this->log->addAlert('Test Alert Occurred');
$this->log->alert('Test Alert Occurred');

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

$this->log->addEmergency('Test Emergency Occurred');
$this->log->emergency('Test Emergency Occurred');

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

0 comments on commit 4079084

Please sign in to comment.