Skip to content

Commit 17cc0c0

Browse files
authored
On monolog config override the log patterns should be filled (#281)
1 parent b1fd746 commit 17cc0c0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ private function normalizeConfig(array $config): array
163163
return $config;
164164
}
165165

166-
$config['monolog']['type'] ??= 'monolog';
167-
$config['monolog']['name'] ??= 'Monolog';
168-
$config['monolog']['finder']['in'] ??= '%kernel.logs_dir%';
169-
$config['monolog']['finder']['name'] ??= '*.log';
170-
$config['monolog']['finder']['depth'] ??= '== 0';
166+
$config['monolog']['type'] ??= 'monolog';
167+
$config['monolog']['name'] ??= 'Monolog';
168+
$config['monolog']['finder']['in'] ??= '%kernel.logs_dir%';
169+
$config['monolog']['finder']['name'] ??= '*.log';
170+
$config['monolog']['finder']['depth'] ??= '== 0';
171+
$config['monolog']['start_of_line_pattern'] ??= MonologLineParser::START_OF_MESSAGE_PATTERN;
172+
$config['monolog']['log_message_pattern'] ??= MonologLineParser::LOG_LINE_PATTERN;
171173

172174
return $config;
173175
}

tests/Integration/DependencyInjection/data/expected-merge-monolog-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"ignoreUnreadableDirs": true,
1313
"followLinks": false
1414
},
15-
"start_of_line_pattern": null,
16-
"log_message_pattern": null,
15+
"start_of_line_pattern": "/^\\[\\d{4}-\\d{2}-\\d{2}[^]]*]\\s+\\S+\\.\\S+:/",
16+
"log_message_pattern": "/^\\[(?P<date>[^\\]]+)\\]\\s+(?P<channel>[^\\.]+)\\.(?P<severity>[^:]+):\\s+(?P<message>.*)\\s+(?P<context>(?:{.*?}|\\[.*?]))\\s+(?P<extra>(?:{.*?}|\\[.*?]))\\s+$/s",
1717
"date_format": null
1818
}
1919
},

tests/Unit/Controller/DeleteFileControllerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PHPUnit\Framework\MockObject\MockObject;
1313
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1414
use Symfony\Component\Filesystem\Filesystem;
15-
use Symfony\Component\HttpFoundation\JsonResponse;
1615
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
1716
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1817

@@ -69,9 +68,8 @@ public function testInvokeSuccess(): void
6968
$this->filesystem->expects(self::once())->method('remove')->with('path');
7069
$this->fileService->expects(self::once())->method('findFileByIdentifier')->with('identifier')->willReturn($logFile);
7170

72-
$expected = new JsonResponse(['success' => true]);
7371
$response = ($this->controller)('identifier');
74-
static::assertEquals($expected, $response);
72+
static::assertEquals('{"success":true}', $response->getContent());
7573
}
7674

7775
public function getController(): AbstractController

0 commit comments

Comments
 (0)