diff --git a/core/includes/common.inc b/core/includes/common.inc index 6e08ce0..8e0d53e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -30,7 +30,6 @@ use Drupal\Core\Template\Attribute; use Drupal\Core\Render\Element; use Drupal\Core\Session\AnonymousUserSession; -use Psr\Log\LogLevel; /** * @defgroup php_wrappers PHP wrapper functions @@ -4100,14 +4099,14 @@ function element_set_attributes(array &$element, array $map) { */ function watchdog_severity_levels() { return array( - LogLevel::EMERGENCY => t('Emergency'), - LogLevel::ALERT => t('Alert'), - LogLevel::CRITICAL => t('Critical'), - LogLevel::ERROR => t('Error'), - LogLevel::WARNING => t('Warning'), - LogLevel::NOTICE => t('Notice'), - LogLevel::INFO => t('Info'), - LogLevel::DEBUG => t('Debug'), + WATCHDOG_EMERGENCY => t('Emergency'), + WATCHDOG_ALERT => t('Alert'), + WATCHDOG_CRITICAL => t('Critical'), + WATCHDOG_ERROR => t('Error'), + WATCHDOG_WARNING => t('Warning'), + WATCHDOG_NOTICE => t('Notice'), + WATCHDOG_INFO => t('Info'), + WATCHDOG_DEBUG => t('Debug'), ); } diff --git a/core/lib/Drupal/Core/Logger/LoggerChannel.php b/core/lib/Drupal/Core/Logger/LoggerChannel.php index 86bf2cf..074cd23 100644 --- a/core/lib/Drupal/Core/Logger/LoggerChannel.php +++ b/core/lib/Drupal/Core/Logger/LoggerChannel.php @@ -29,20 +29,19 @@ class LoggerChannel implements LoggerChannelInterface { /** * Map of PSR Log constants to Watchdog log constants. * - * This only exists for BC. - * @todo Remove once watchdog() is removed. + * @todo Move watchdog constants here when watchdog() is removed. * * @var array */ protected $levelTranslation = array( - WATCHDOG_EMERGENCY => LogLevel::EMERGENCY, - WATCHDOG_ALERT => LogLevel::ALERT, - WATCHDOG_CRITICAL => LogLevel::CRITICAL, - WATCHDOG_ERROR => LogLevel::ERROR, - WATCHDOG_WARNING => LogLevel::WARNING, - WATCHDOG_NOTICE => LogLevel::NOTICE, - WATCHDOG_INFO => LogLevel::INFO, - WATCHDOG_DEBUG => LogLevel::DEBUG, + LogLevel::EMERGENCY => WATCHDOG_EMERGENCY, + LogLevel::ALERT => WATCHDOG_ALERT, + LogLevel::CRITICAL => WATCHDOG_CRITICAL, + LogLevel::ERROR => WATCHDOG_ERROR, + LogLevel::WARNING => WATCHDOG_WARNING, + LogLevel::NOTICE => WATCHDOG_NOTICE, + LogLevel::INFO => WATCHDOG_INFO, + LogLevel::DEBUG => WATCHDOG_DEBUG, ); /** @@ -102,10 +101,8 @@ public function log($level, $message, array $context = array()) { $context['ip'] = $this->request->getClientIP(); } - if (!is_string($level)) { - // Convert integer levels (WATCHDOG_* constants) to the string equivalents - // of \Psr\Log\LogLevel. - // @todo Remove this when watchdog() is removed. + if (is_string($level)) { + // Convert to integer equivalent for consistency with RFC 3164. $level = $this->levelTranslation[$level]; } // Call all available loggers. diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index a6ceaf0..b7454c1 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -44,11 +44,12 @@ function dblog_schema() { 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.', ), 'severity' => array( - 'type' => 'varchar', - 'length' => 64, + 'type' => 'int', + 'unsigned' => TRUE, 'not null' => TRUE, - 'default' => '', - 'description' => 'The severity level of the event. See \Psr\Log\LogLevel', + 'default' => 0, + 'size' => 'tiny', + 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)', ), 'link' => array( 'type' => 'varchar', diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php index 08123b3..72ddf22 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php @@ -15,7 +15,6 @@ use Drupal\Core\Datetime\Date; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; -use Psr\Log\LogLevel; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -90,14 +89,14 @@ public function __construct(Connection $database, ModuleHandlerInterface $module */ public static function getLogLevelClassMap() { return array( - LogLevel::DEBUG => 'dblog-debug', - LogLevel::INFO => 'dblog-info', - LogLevel::NOTICE => 'dblog-notice', - LogLevel::WARNING => 'dblog-warning', - LogLevel::ERROR => 'dblog-error', - LogLevel::CRITICAL => 'dblog-critical', - LogLevel::ALERT => 'dblog-alert', - LogLevel::EMERGENCY => 'dblog-emergency', + WATCHDOG_DEBUG => 'dblog-debug', + WATCHDOG_INFO => 'dblog-info', + WATCHDOG_NOTICE => 'dblog-notice', + WATCHDOG_WARNING => 'dblog-warning', + WATCHDOG_ERROR => 'dblog-error', + WATCHDOG_CRITICAL => 'dblog-critical', + WATCHDOG_ALERT => 'dblog-alert', + WATCHDOG_EMERGENCY => 'dblog-emergency', ); } diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php index a16625b..84c05cf 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php @@ -11,7 +11,6 @@ use Drupal\Core\Language\Language; use Drupal\dblog\Controller\DbLogController; use Drupal\simpletest\WebTestBase; -use Psr\Log\LogLevel; /** * Tests logging messages to the database. @@ -124,10 +123,9 @@ private function verifyCron($row_limit) { * @param string $type * (optional) The type of watchdog entry. Defaults to 'custom'. * @param int $severity - * (optional) The severity of the watchdog entry. - * Defaults to \Psr\Log\LogLevel::NOTICE. + * (optional) The severity of the watchdog entry. Defaults to WATCHDOG_NOTICE. */ - private function generateLogEntries($count, $type = 'custom', $severity = LogLevel::NOTICE) { + private function generateLogEntries($count, $type = 'custom', $severity = WATCHDOG_NOTICE) { global $base_root; // Prepare the fields to be logged @@ -418,7 +416,7 @@ protected function testDBLogAddAndClear() { 'channel' => 'system', 'message' => 'Log entry added to test the doClearTest clear down.', 'variables' => array(), - 'severity' => LogLevel::NOTICE, + 'severity' => WATCHDOG_NOTICE, 'link' => NULL, 'user' => $this->big_user, 'uid' => $this->big_user->id(), @@ -454,15 +452,12 @@ protected function testFilter() { $types = array(); for ($i = 0; $i < 3; $i++) { $type_names[] = $type_name = $this->randomName(); + $severity = WATCHDOG_EMERGENCY; for ($j = 0; $j < 3; $j++) { - $severity = LogLevel::EMERGENCY; - if ($j) { - $severity = $j === 1 ? LogLevel::ALERT : LogLevel::CRITICAL; - } $types[] = $type = array( 'count' => $j + 1, 'type' => $type_name, - 'severity' => $severity, + 'severity' => $severity++, ); $this->generateLogEntries($type['count'], $type['type'], $type['severity']); } diff --git a/core/modules/syslog/lib/Drupal/syslog/Logger/SysLog.php b/core/modules/syslog/lib/Drupal/syslog/Logger/SysLog.php index 7b3ecd0..8dbb618 100644 --- a/core/modules/syslog/lib/Drupal/syslog/Logger/SysLog.php +++ b/core/modules/syslog/lib/Drupal/syslog/Logger/SysLog.php @@ -11,7 +11,6 @@ use Drupal\Core\Logger\LogMessageParserInterface; use Psr\Log\LoggerInterface; use Psr\Log\LoggerTrait; -use Psr\Log\LogLevel; /** * Redirects logging messages to syslog. @@ -41,25 +40,6 @@ class SysLog implements LoggerInterface { protected $connectionOpened = FALSE; /** - * Map of PSR Log constants to Watchdog log constants. - * - * @todo Move watchdog constants to syslog's module namespace, after - * watchdog() is removed. - * - * @var array - */ - protected $levelTranslation = array( - LogLevel::EMERGENCY => WATCHDOG_EMERGENCY, - LogLevel::ALERT => WATCHDOG_ALERT, - LogLevel::CRITICAL => WATCHDOG_CRITICAL, - LogLevel::ERROR => WATCHDOG_ERROR, - LogLevel::WARNING => WATCHDOG_WARNING, - LogLevel::NOTICE => WATCHDOG_NOTICE, - LogLevel::INFO => WATCHDOG_INFO, - LogLevel::DEBUG => WATCHDOG_DEBUG, - ); - - /** * Constructs a SysLog object. * * @param \Drupal\Core\Config\ConfigFactory $config_factory @@ -110,7 +90,7 @@ public function log($level, $message, array $context = array()) { '!message' => strip_tags($message), )); - syslog($this->levelTranslation[$level], $entry); + syslog($level, $entry); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php index 253b145..1f47cc9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/InstallUninstallTest.php @@ -7,8 +7,6 @@ namespace Drupal\system\Tests\Module; -use Psr\Log\LogLevel; - /** * Tests functionality for installing and uninstalling modules. */ @@ -100,7 +98,7 @@ public function testInstallUninstall() { $this->assertModules(array($module_to_install), TRUE); $this->assertModuleTablesExist($module_to_install); $this->assertModuleConfig($module_to_install); - $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_install), LogLevel::INFO); + $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_install), WATCHDOG_INFO); } // Uninstall the original module, and check appropriate @@ -169,7 +167,7 @@ protected function assertSuccessfullUninstall($module, $package = 'Core') { // module was just uninstalled, since the {watchdog} table won't be there // anymore.) $this->assertText(t('hook_modules_uninstalled fired for @module', array('@module' => $module))); - $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module), LogLevel::INFO); + $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module), WATCHDOG_INFO); // Check that the module's database tables no longer exist. $this->assertModuleTablesDoNotExist($module); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index 38300d9..0ce14fe 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -11,7 +11,6 @@ use Drupal\Core\Database\Database; use Drupal\Core\Config\FileStorage; use Drupal\simpletest\WebTestBase; -use Psr\Log\LogLevel; /** * Helper class for module test cases. @@ -185,7 +184,7 @@ function assertModules(array $modules, $enabled) { * @param $link * A link to associate with the message. */ - function assertLogMessage($type, $message, $variables = array(), $severity = LogLevel::NOTICE, $link = '') { + function assertLogMessage($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = '') { $count = db_select('watchdog', 'w') ->condition('type', $type) ->condition('message', $message)