Skip to content

Commit

Permalink
MOL-1124: do not load settings without db
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Oct 19, 2023
1 parent 159513e commit 0d4fc8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Resources/config/services/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<argument type="service" id="Kiener\MolliePayments\Service\SettingsService"/>
<argument>%kernel.logs_dir%/mollie_%kernel.environment%.log</argument>
<argument>14</argument>
<argument>%env(DATABASE_URL)%</argument>
</service>

<service id="mollie_payments.logger" class="Monolog\Logger">
Expand Down
11 changes: 10 additions & 1 deletion src/Service/Logger/MollieLoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,34 @@ class MollieLoggerFactory
* @var string
*/
private $retentionDays;
private string $dsn;


/**
* @param SettingsService $settingsService
* @param string $filename
* @param string $retentionDays
* @param string $dsn
*/
public function __construct(SettingsService $settingsService, string $filename, string $retentionDays)
public function __construct(SettingsService $settingsService, string $filename, string $retentionDays, string $dsn)
{
$this->settingsService = $settingsService;
$this->filename = $filename;
$this->retentionDays = $retentionDays;
$this->dsn = $dsn;
}

/**
* @return LoggerInterface
*/
public function createLogger(): LoggerInterface
{

if ($this->dsn === '' || $this->dsn === 'mysql://_placeholder.test') {
// deployment server without database
return new Logger(self::CHANNEL);
}

$config = $this->settingsService->getSettings();

# 100 = DEBUG, 200 = INFO
Expand Down

0 comments on commit 0d4fc8d

Please sign in to comment.