have Drupal forward logs to actual logs
This commit is contained in:
parent
642dee3c1f
commit
27e2b6f2d9
5 changed files with 50 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
locales \
|
locales \
|
||||||
curl \
|
curl \
|
||||||
gettext-base \
|
gettext-base \
|
||||||
|
procps \
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
||||||
&& apt-get install -y nodejs \
|
&& apt-get install -y nodejs \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,26 @@ $DRUSH en -y views views_ui field_ui text options link datetime && \
|
||||||
echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed."
|
echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed."
|
||||||
$DRUSH en -y webform webform_ui && \
|
$DRUSH en -y webform webform_ui && \
|
||||||
echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed."
|
echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed."
|
||||||
$DRUSH en -y symfony_mailer && \
|
$DRUSH en -y symfony_mailer mailer_transport && \
|
||||||
echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed."
|
echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed."
|
||||||
|
|
||||||
|
if [ -n "${POSTMARK_API_KEY:-}" ]; then
|
||||||
|
$DRUSH php:eval "
|
||||||
|
\$storage = \Drupal::entityTypeManager()->getStorage('mailer_transport');
|
||||||
|
if (!\$storage->load('postmark')) {
|
||||||
|
\$storage->create([
|
||||||
|
'id' => 'postmark',
|
||||||
|
'label' => 'Postmark',
|
||||||
|
'plugin' => 'smtp',
|
||||||
|
'configuration' => ['dsn' => 'postmark+api://' . getenv('POSTMARK_API_KEY') . '@default'],
|
||||||
|
])->save();
|
||||||
|
}
|
||||||
|
\$config = \Drupal::configFactory()->getEditable('mailer_transport.settings');
|
||||||
|
\$config->set('default_transport', 'postmark')->save();
|
||||||
|
\Drupal::configFactory()->getEditable('system.mail')
|
||||||
|
->set('interface.default', 'symfony_mailer')->save();
|
||||||
|
" && echo "[entrypoint] Postmark transport configured." || echo "[entrypoint] WARNING: Postmark transport setup failed."
|
||||||
|
fi
|
||||||
$DRUSH en -y riverside_pt && \
|
$DRUSH en -y riverside_pt && \
|
||||||
echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed."
|
echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
services:
|
||||||
|
riverside_pt.php_error_logger:
|
||||||
|
class: Drupal\riverside_pt\Logger\PhpErrorLogger
|
||||||
|
tags:
|
||||||
|
- { name: logger }
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\riverside_pt\Logger;
|
||||||
|
|
||||||
|
use Drupal\Core\Logger\RfcLogLevel;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Psr\Log\LoggerTrait;
|
||||||
|
|
||||||
|
class PhpErrorLogger implements LoggerInterface {
|
||||||
|
use LoggerTrait;
|
||||||
|
|
||||||
|
private const LABELS = ['emergency', 'alert', 'critical', 'error', 'warning'];
|
||||||
|
|
||||||
|
public function log($level, $message, array $context = []): void {
|
||||||
|
if ($level > RfcLogLevel::WARNING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$channel = $context['channel'] ?? 'drupal';
|
||||||
|
$severity = self::LABELS[$level] ?? 'unknown';
|
||||||
|
$formatted = strtr($message, array_filter($context, 'is_scalar'));
|
||||||
|
error_log(sprintf('[drupal/%s] %s: %s', $channel, strtoupper($severity), $formatted));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,19 +20,12 @@ $settings['hash_salt'] = getenv('HASH_SALT') ?: 'replace-this-in-production';
|
||||||
$settings['update_free_access'] = FALSE;
|
$settings['update_free_access'] = FALSE;
|
||||||
|
|
||||||
$is_dev = (bool) getenv('DEBUG');
|
$is_dev = (bool) getenv('DEBUG');
|
||||||
$postmark_key = getenv('POSTMARK_API_KEY');
|
|
||||||
|
|
||||||
if ($is_dev) {
|
if ($is_dev) {
|
||||||
$config['system.mail']['interface']['default'] = 'php_mail';
|
$config['system.mail']['interface']['default'] = 'php_mail';
|
||||||
} else {
|
} elseif (!getenv('POSTMARK_API_KEY')) {
|
||||||
if (!$postmark_key) {
|
|
||||||
throw new \RuntimeException('POSTMARK_API_KEY is not set — refusing to start without a mail transport.');
|
throw new \RuntimeException('POSTMARK_API_KEY is not set — refusing to start without a mail transport.');
|
||||||
}
|
}
|
||||||
$config['symfony_mailer.mailer_transport.postmark']['configuration']['dsn'] =
|
|
||||||
'postmark+api://' . $postmark_key . '@default';
|
|
||||||
$config['mailer_transport.settings']['default_transport'] = 'postmark';
|
|
||||||
$config['system.mail']['interface']['default'] = 'symfony_mailer';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable CSS/JS aggregation — assets served directly from source paths.
|
// Disable CSS/JS aggregation — assets served directly from source paths.
|
||||||
$config['system.performance']['css']['preprocess'] = FALSE;
|
$config['system.performance']['css']['preprocess'] = FALSE;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue