Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Default configuration: [(Configuration reference)](https://github.com/frankdekke
```yaml
fd_log_viewer:
home_route: null
show_performance_details: true

log_files:
monolog:
Expand Down
7 changes: 7 additions & 0 deletions docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Out of the box, [Log viewer](../README.md) will have the following configuration
```yaml
fd_log_viewer:
home_route: null
show_performance_details: true

log_files:
monolog:
Expand Down Expand Up @@ -39,6 +40,12 @@ fd_log_viewer:
The name of the route that will be used as url for the back button. If null the back button will redirect to `https://your-domain/`.
<br><br>

### show_performance_details
type: `boolean`. Default: `true`

Show the performance details (memory, duration and package version) in the footer or not.
<br><br>

### log_files

**type**: `array<string, mixed>`
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public function getConfigTreeBuilder(): TreeBuilder
$rootNode
->children()
->scalarNode('home_route')->info("The name of the route to redirect to when clicking the back button")->end()
->scalarNode('show_performance_details')
->defaultTrue()
->info("Will toggle if the performance information and version will be shown. Default true")
->end()
->append($this->configureLogFiles())
->append($this->configureHosts());

Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FD\LogViewer\Entity\Config\HostAuthenticationConfig;
use FD\LogViewer\Entity\Config\HostConfig;
use FD\LogViewer\Entity\Config\LogFilesConfig;
use FD\LogViewer\Service\File\LogRecordsOutputProvider;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension;
Expand All @@ -33,6 +34,10 @@ public function load(array $configs, ContainerBuilder $container): void

$container->setParameter('fd.symfony.log.viewer.log_files_config.home_route', $mergedConfigs['home_route'] ?? null);

if ($mergedConfigs['show_performance_details'] === false) {
$container->getDefinition(LogRecordsOutputProvider::class)->setArgument('$performanceService', null);
}

foreach ($mergedConfigs['log_files'] as $key => $config) {
$container->register('fd.symfony.log.viewer.log_files_config.finder.' . $key, FinderConfig::class)
->setPublic(false)
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Output/LogRecordsOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LogRecordsOutput implements JsonSerializable
public function __construct(
private readonly array $records,
private readonly ?Paginator $paginator,
private readonly PerformanceStats $performance
private readonly ?PerformanceStats $performance
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Service/File/LogRecordsOutputProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LogRecordsOutputProvider
public function __construct(
private readonly LogFileParserProvider $logParserProvider,
private readonly LogRecordsNormalizer $logRecordsNormalizer,
private readonly PerformanceService $performanceService,
private readonly ?PerformanceService $performanceService,
) {
}

Expand All @@ -44,7 +44,7 @@ public function provideForFiles(array $files, LogQueryDto $logQuery): LogRecords
return new LogRecordsOutput(
$this->logRecordsNormalizer->normalize($logRecordCollection->getRecords(), $logQuery->timeZone),
$logRecordCollection->getPaginator(),
$this->performanceService->getPerformanceStats()
$this->performanceService?->getPerformanceStats()
);
}

Expand All @@ -56,7 +56,7 @@ public function provide(LogFile $file, LogQueryDto $logQuery): LogRecordsOutput
return new LogRecordsOutput(
$this->logRecordsNormalizer->normalize($logRecordCollection->getRecords(), $logQuery->timeZone),
$logRecordCollection->getPaginator(),
$this->performanceService->getPerformanceStats()
$this->performanceService?->getPerformanceStats()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"show_performance_details": true,
"log_files": {
"monolog": {
"type": "monolog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}
}
},
"show_performance_details": true,
"log_files": {
"monolog": {
"type": "monolog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"date_format": null
}
},
"show_performance_details": true,
"hosts": {
"localhost": {
"name": "Local",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"date_format": null
}
},
"show_performance_details": true,
"hosts": {
"localhost": {
"name": "Local",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fd_log_viewer": {
"home_route": "home",
"show_performance_details": true,
"log_files": {
"monolog": {
"type": "monolog",
Expand Down