Skip to content

Commit

Permalink
Monolog 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
eth8505 committed Aug 13, 2024
1 parent 7f5e04a commit af548b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"monolog/monolog": "^1.24 || ^2.0",
"php": "^8.1",
"monolog/monolog": "^3.0",
"laminas/laminas-servicemanager": "^3.0",
"laminas/laminas-stdlib": "^3.2"
},
Expand All @@ -26,7 +26,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^10.5"
},
"extra": {
"zf": {
Expand Down
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Laminas Monolog Module Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
12 changes: 7 additions & 5 deletions test/Factory/LoggerAbstractFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
use Monolog\Formatter\ChromePHPFormatter;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Processor\ProcessIdProcessor;
use PHPUnit\Framework\TestCase;
use Laminas\ServiceManager\ServiceManager;
use Psr\Log\LogLevel;

class LoggerAbstractFactoryTest extends TestCase
{
Expand Down Expand Up @@ -196,7 +198,7 @@ public function testDefaultLevelIsApplied(): void {
$container->setService('Config', [
'monolog' => [
'defaults' => [
'level' => 123
'level' => Level::Alert
],
'loggers' => [
'base' => [
Expand Down Expand Up @@ -226,7 +228,7 @@ public function testDefaultLevelIsApplied(): void {

$factory = new LoggerAbstractFactory();

self::assertEquals(123, $factory($container, 'base')->getHandlers()[0]->getLevel());
self::assertEquals(Level::Alert, $factory($container, 'base')->getHandlers()[0]->getLevel());

}

Expand All @@ -235,7 +237,7 @@ public function testDefaultLevelDoesNotOverrideConfiguredLevel(): void {
$container->setService('Config', [
'monolog' => [
'defaults' => [
'level' => 123
'level' => Level::Alert
],
'loggers' => [
'base' => [
Expand All @@ -245,7 +247,7 @@ public function testDefaultLevelDoesNotOverrideConfiguredLevel(): void {
'name' => StreamHandler::class,
'options' => [
'stream' => STDOUT,
'level' => 100
'level' => Level::Debug
]
]
]
Expand All @@ -266,7 +268,7 @@ public function testDefaultLevelDoesNotOverrideConfiguredLevel(): void {

$factory = new LoggerAbstractFactory();

self::assertEquals(100, $factory($container, 'base')->getHandlers()[0]->getLevel());
self::assertEquals(Level::Debug, $factory($container, 'base')->getHandlers()[0]->getLevel());

}

Expand Down

0 comments on commit af548b3

Please sign in to comment.