Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOL-1124: do not load settings without db #644

Merged
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 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
Loading