Skip to content

Commit

Permalink
MOL-1124: do not load settings without db (#644)
Browse files Browse the repository at this point in the history
* MOL-1124: do not load settings without db

* MOL-1124: code style

* MOL-1124: CS Fix

---------

Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik authored Oct 20, 2023
1 parent 1a636a8 commit 315f7a0
Show file tree
Hide file tree
Showing 2 changed files with 14 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
14 changes: 13 additions & 1 deletion src/Service/Logger/MollieLoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,36 @@ class MollieLoggerFactory
*/
private $retentionDays;

/**
* @var string
*/
private $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 315f7a0

Please sign in to comment.