Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -1,3 +1,6 @@
|
|||
identity: drupal
|
||||
facility: ''
|
||||
# The default facility setting depends on the operating system, and will be
|
||||
# overwritten during installation.
|
||||
# @see syslog_install().
|
||||
facility: 8
|
||||
format: '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'
|
||||
|
|
|
@ -8,7 +8,7 @@ syslog.settings:
|
|||
type: string
|
||||
label: 'Identity'
|
||||
facility:
|
||||
type: string
|
||||
type: integer
|
||||
label: 'Facility'
|
||||
format:
|
||||
type: string
|
||||
|
|
|
@ -2,11 +2,13 @@ id: d6_syslog_settings
|
|||
label: System log configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- syslog_identity
|
||||
- syslog_facility
|
||||
source_module: syslog
|
||||
process:
|
||||
identity: syslog_identity
|
||||
facility: syslog_facility
|
|
@ -2,12 +2,14 @@ id: d7_syslog_settings
|
|||
label: Syslog configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- syslog_facility
|
||||
- syslog_format
|
||||
- syslog_identity
|
||||
source_module: syslog
|
||||
process:
|
||||
facility: syslog_facility
|
||||
format: syslog_format
|
|
@ -77,11 +77,24 @@ class SysLog implements LoggerInterface {
|
|||
'!ip' => $context['ip'],
|
||||
'!request_uri' => $context['request_uri'],
|
||||
'!referer' => $context['referer'],
|
||||
'!severity' => $level,
|
||||
'!uid' => $context['uid'],
|
||||
'!link' => strip_tags($context['link']),
|
||||
'!message' => strip_tags($message),
|
||||
]);
|
||||
|
||||
$this->syslogWrapper($level, $entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* A syslog wrapper to make syslog functionality testable.
|
||||
*
|
||||
* @param int $level
|
||||
* The syslog priority.
|
||||
* @param string $entry
|
||||
* The message to send to syslog function.
|
||||
*/
|
||||
protected function syslogWrapper($level, $entry) {
|
||||
syslog($level, $entry);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,3 +13,12 @@ function syslog_install() {
|
|||
// to be set dynamically during installation.
|
||||
\Drupal::configFactory()->getEditable('syslog.settings')->set('facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert syslog.settings.facility to an integer.
|
||||
*/
|
||||
function syslog_update_8400() {
|
||||
$config = \Drupal::configFactory()->getEditable('syslog.settings');
|
||||
$facility = (int) $config->get('facility');
|
||||
$config->set('facility', $facility)->save(TRUE);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $f
|
|||
'#type' => 'textarea',
|
||||
'#title' => t('Syslog format'),
|
||||
'#default_value' => $config->get('format'),
|
||||
'#description' => t('Specify the format of the syslog entry. Available variables are: <dl><dt><code>!base_url</code></dt><dd>Base URL of the site.</dd><dt><code>!timestamp</code></dt><dd>Unix timestamp of the log entry.</dd><dt><code>!type</code></dt><dd>The category to which this message belongs.</dd><dt><code>!ip</code></dt><dd>IP address of the user triggering the message.</dd><dt><code>!request_uri</code></dt><dd>The requested URI.</dd><dt><code>!referer</code></dt><dd>HTTP Referer if available.</dd><dt><code>!uid</code></dt><dd>User ID.</dd><dt><code>!link</code></dt><dd>A link to associate with the message.</dd><dt><code>!message</code></dt><dd>The message to store in the log.</dd></dl>'),
|
||||
'#description' => t('Specify the format of the syslog entry. Available variables are: <dl><dt><code>!base_url</code></dt><dd>Base URL of the site.</dd><dt><code>!timestamp</code></dt><dd>Unix timestamp of the log entry.</dd><dt><code>!type</code></dt><dd>The category to which this message belongs.</dd><dt><code>!ip</code></dt><dd>IP address of the user triggering the message.</dd><dt><code>!request_uri</code></dt><dd>The requested URI.</dd><dt><code>!referer</code></dt><dd>HTTP Referer if available.</dd><dt><code>!severity</code></dt><dd>The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).</dd><dt><code>!uid</code></dt><dd>User ID.</dd><dt><code>!link</code></dt><dd>A link to associate with the message.</dd><dt><code>!message</code></dt><dd>The message to store in the log.</dd></dl>'),
|
||||
];
|
||||
|
||||
$form['#submit'][] = 'syslog_logging_settings_submit';
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\syslog_test\Logger;
|
||||
|
||||
use Drupal\syslog\Logger\SysLog;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Redirects logging messages to error_log.
|
||||
*/
|
||||
class SysLogTest extends SysLog implements LoggerInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function syslogWrapper($level, $entry) {
|
||||
$log_path = \Drupal::service('file_system')->realpath('public://syslog.log');
|
||||
error_log($entry . PHP_EOL, 3, $log_path);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
name: 'Syslog test'
|
||||
type: module
|
||||
description: 'Provides a test logger for syslog module.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- drupal:syslog
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
logger.syslog_test:
|
||||
parent: logger.syslog
|
||||
class: Drupal\syslog_test\Logger\SysLogTest
|
||||
arguments: ['@config.factory', '@logger.log_message_parser']
|
||||
tags:
|
||||
- { name: logger }
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\syslog\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Tests that syslog settings are properly updated during database updates.
|
||||
*
|
||||
* @group syslog
|
||||
* @group legacy
|
||||
*/
|
||||
class SyslogUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that syslog.settings.facility has been converted from string to int.
|
||||
*
|
||||
* @see syslog_update_8400()
|
||||
*/
|
||||
public function testSyslogSettingsFacilityDataType() {
|
||||
$config = $this->config('syslog.settings');
|
||||
$this->assertIdentical('128', $config->get('facility'));
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
$config = $this->config('syslog.settings');
|
||||
$this->assertIdentical(128, $config->get('facility'));
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,7 @@ class MigrateSyslogConfigsTest extends MigrateDrupal6TestBase {
|
|||
public function testSyslogSettings() {
|
||||
$config = $this->config('syslog.settings');
|
||||
$this->assertIdentical('drupal', $config->get('identity'));
|
||||
$this->assertIdentical('128', $config->get('facility'));
|
||||
$this->assertIdentical(128, $config->get('facility'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'syslog.settings', $config->get());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class MigrateSyslogConfigsTest extends MigrateDrupal7TestBase {
|
|||
public function testSyslogSettings() {
|
||||
$config = $this->config('syslog.settings');
|
||||
// 8 == LOG_USER
|
||||
$this->assertIdentical('8', $config->get('facility'));
|
||||
$this->assertIdentical(8, $config->get('facility'));
|
||||
$this->assertIdentical('!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message', $config->get('format'));
|
||||
$this->assertIdentical('drupal', $config->get('identity'));
|
||||
}
|
||||
|
|
78
web/core/modules/syslog/tests/src/Kernel/SyslogTest.php
Normal file
78
web/core/modules/syslog/tests/src/Kernel/SyslogTest.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\syslog\Kernel;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Test syslog logger functionality.
|
||||
*
|
||||
* @group syslog
|
||||
* @coversDefaultClass \Drupal\syslog\Logger\SysLog
|
||||
*/
|
||||
class SyslogTest extends KernelTestBase {
|
||||
|
||||
public static $modules = ['syslog', 'syslog_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installConfig(['syslog']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::log
|
||||
*/
|
||||
public function testSyslogWriting() {
|
||||
|
||||
$request = Request::create('/page-not-found', 'GET', [], [], [], ['REMOTE_ADDR' => '1.2.3.4']);
|
||||
$request->headers->set('Referer', 'other-site');
|
||||
\Drupal::requestStack()->push($request);
|
||||
|
||||
$user = $this->getMockBuilder('Drupal\Core\Session\AccountInterface')->getMock();
|
||||
$user->method('id')->willReturn(42);
|
||||
$this->container->set('current_user', $user);
|
||||
|
||||
\Drupal::logger('my_module')->warning('My warning message.', ['link' => '/my-link']);
|
||||
|
||||
$log_filename = $this->container->get('file_system')->realpath('public://syslog.log');
|
||||
$logs = explode(PHP_EOL, file_get_contents($log_filename));
|
||||
$log = explode('|', $logs[0]);
|
||||
|
||||
global $base_url;
|
||||
$this->assertEquals($base_url, $log[0]);
|
||||
$this->assertEquals('my_module', $log[2]);
|
||||
$this->assertEquals('1.2.3.4', $log[3]);
|
||||
$this->assertEquals($base_url . '/page-not-found', $log[4]);
|
||||
$this->assertEquals('other-site', $log[5]);
|
||||
$this->assertEquals('42', $log[6]);
|
||||
$this->assertEquals('/my-link', $log[7]);
|
||||
$this->assertEquals('My warning message.', $log[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test severity level logging.
|
||||
*
|
||||
* @covers ::log
|
||||
*/
|
||||
public function testSyslogSeverity() {
|
||||
/* @var \Drupal\Core\Config\Config $config */
|
||||
$config = $this->container->get('config.factory')->getEditable('syslog.settings');
|
||||
$config->set('format', '!type|!message|!severity');
|
||||
$config->save();
|
||||
|
||||
\Drupal::logger('my_module')->warning('My warning message.');
|
||||
|
||||
$log_filename = $this->container->get('file_system')->realpath('public://syslog.log');
|
||||
$logs = explode(PHP_EOL, file_get_contents($log_filename));
|
||||
$log = explode('|', $logs[0]);
|
||||
|
||||
$this->assertEquals('my_module', $log[0]);
|
||||
$this->assertEquals('My warning message.', $log[1]);
|
||||
$this->assertEquals('4', $log[2]);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue