summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-08-27 07:18:06 +0000
committerDries Buytaert <dries@buytaert.net>2009-08-27 07:18:06 +0000
commit2d6053f8569eb5eb7d5726af907f2a0b99d9ac25 (patch)
tree2ceb64ffd04498c286609c16b965a70d97a74279
parent0259ee968ffa4db893e57a80931aaf9f8ae69e5e (diff)
downloadbrdo-2d6053f8569eb5eb7d5726af907f2a0b99d9ac25.tar.gz
brdo-2d6053f8569eb5eb7d5726af907f2a0b99d9ac25.tar.bz2
- Patch #395378 by Xano: syslog module clean-up and bugfix.
-rw-r--r--modules/syslog/syslog.module62
-rw-r--r--modules/syslog/syslog.test22
2 files changed, 43 insertions, 41 deletions
diff --git a/modules/syslog/syslog.module b/modules/syslog/syslog.module
index afcf83101..224763b2c 100644
--- a/modules/syslog/syslog.module
+++ b/modules/syslog/syslog.module
@@ -19,9 +19,13 @@ else {
function syslog_help($path, $arg) {
switch ($path) {
case 'admin/help#syslog':
- $output = '<p>' . t("The syslog module enables Drupal to send messages to the operating system's logging facility.") . '</p>';
- $output .= '<p>' . t('Syslog is an operating system administrative logging tool, and provides valuable information for use in system management and security auditing. Most suited to medium and large sites, syslog provides filtering tools that allow messages to be routed by type and severity. On UNIX/Linux systems, the file /etc/syslog.conf defines this routing configuration; on Microsoft Windows, all messages are sent to the Event Log. For more information on syslog facilities, severity levels, and how to set up a syslog.conf file, see <a href="@syslog_conf">UNIX/Linux syslog.conf</a> and PHP\'s <a href="@php_openlog">openlog</a> and <a href="@php_syslog">syslog</a> functions.', array('@syslog_conf' => url('http://www.rt.com/man/syslog.5.html'), '@php_openlog' => url('http://www.php.net/manual/function.openlog.php'), '@php_syslog' => url('http://www.php.net/manual/function.syslog.php'))) . '</p>';
- $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@syslog">Syslog module</a>.', array('@syslog' => 'http://drupal.org/handbook/modules/syslog')) . '</p>';
+ $output = '<p>' . t("Syslog logs events by sending messages to the logging facility of your web server's operating system. Syslog is an operating system administrative logging tool, and provides valuable information for use in system management and security auditing. Most suited to medium and large sites, syslog provides filtering tools that allow messages to be routed by type and severity.") . '</p>';
+ $output .= '<h2>' . t('UNIX, Linux & Mac OS X') . '</h2>';
+ $output .= '<p>' . t('On UNIX, Linux and Mac OS X, the file /etc/syslog.conf defines this routing configuration. Messages can be flagged with the codes <code>LOG_LOCAL0</code> through <code>LOG_LOCAL7</code>. For information on syslog facilities, severity levels, and how to set up <code>syslog.conf</code>, see the <a href="@syslog_conf"><code>syslog.conf</code> manual page</a>.', array('@syslog_conf' => url('http://www.rt.com/man/syslog.5.html'))) . '</p>';
+ $output .= '<h2>' . t('Microsoft Windows') . '</h2>';
+ $output .= '<p>' . t('On Microsoft Windows messages are always sent to the Event Log using the code <code>LOG_USER</code>.') . '</p>';
+ $output .= '<p>' . t('For more information, see the <a href="@syslog">online handbook</a> and and PHP\'s <a href="@php_openlog">openlog</a> and <a href="@php_syslog">syslog</a> functions.', array('@syslog' => 'http://drupal.org/handbook/modules/syslog', '@php_openlog' => url('http://www.php.net/manual/function.openlog.php'), '@php_syslog' => url('http://www.php.net/manual/function.syslog.php'))) . '</p>';
+
return $output;
}
}
@@ -30,34 +34,35 @@ function syslog_help($path, $arg) {
* Implement hook_form_FORM_ID_alter().
*/
function syslog_form_system_logging_settings_alter(&$form, &$form_state) {
- $form['syslog_facility'] = array(
- '#type' => 'select',
- '#title' => t('Send events to this syslog facility'),
- '#default_value' => variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY),
- '#options' => syslog_facility_list(),
- '#description' => t('Select the syslog facility code under which Drupal\'s messages should be sent. On UNIX/Linux systems, Drupal can flag its messages with the code LOG_LOCAL0 through LOG_LOCAL7; for Microsoft Windows, all messages are flagged with the code LOG_USER. Depending on the system configuration, syslog and other logging tools use this code to identify or filter Drupal messages from within the entire system log. For more information on syslog, see <a href="@syslog_help">Syslog help</a>.', array(
- '@syslog_help' => url('admin/help/syslog'))),
- );
- $form['buttons']['#weight'] = 1;
+ if (defined('LOG_LOCAL0')) {
+ $help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL;
+ $form['syslog_facility'] = array(
+ '#type' => 'select',
+ '#title' => t('Syslog facility'),
+ '#default_value' => variable_get('syslog_facility', LOG_LOCAL0),
+ '#options' => syslog_facility_list(),
+ '#description' => t('Depending on the system configuration, Syslog and other logging tools use this code to identify or filter messages from within the entire system log.') . $help,
+ );
+ $form['buttons']['#weight'] = 1;
+ }
}
+ /**
+ * List all possible syslog facilities for UNIX/Linux.
+ *
+ * @return array
+ */
function syslog_facility_list() {
- $facility_list = array(
- LOG_USER => t('LOG_USER - User level messages. Use this for Windows.'),
+ return array(
+ LOG_LOCAL0 => 'LOG_LOCAL0',
+ LOG_LOCAL1 => 'LOG_LOCAL1',
+ LOG_LOCAL2 => 'LOG_LOCAL2',
+ LOG_LOCAL3 => 'LOG_LOCAL3',
+ LOG_LOCAL4 => 'LOG_LOCAL4',
+ LOG_LOCAL5 => 'LOG_LOCAL5',
+ LOG_LOCAL6 => 'LOG_LOCAL6',
+ LOG_LOCAL7 => 'LOG_LOCAL7',
);
- if (defined('LOG_LOCAL0')) {
- $facility_list += array(
- LOG_LOCAL0 => t('LOG_LOCAL0 - Local 0'),
- LOG_LOCAL1 => t('LOG_LOCAL1 - Local 1'),
- LOG_LOCAL2 => t('LOG_LOCAL2 - Local 2'),
- LOG_LOCAL3 => t('LOG_LOCAL3 - Local 3'),
- LOG_LOCAL4 => t('LOG_LOCAL4 - Local 4'),
- LOG_LOCAL5 => t('LOG_LOCAL5 - Local 5'),
- LOG_LOCAL6 => t('LOG_LOCAL6 - Local 6'),
- LOG_LOCAL7 => t('LOG_LOCAL7 - Local 7'),
- );
- }
- return $facility_list;
}
/**
@@ -68,7 +73,8 @@ function syslog_watchdog(array $log_entry) {
if (!$log_init) {
$log_init = TRUE;
- openlog('drupal', LOG_NDELAY, variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY));
+ $default_facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER;
+ openlog('drupal', LOG_NDELAY, variable_get('syslog_facility', $default_facility));
}
syslog($log_entry['severity'], theme('syslog_format', $log_entry));
diff --git a/modules/syslog/syslog.test b/modules/syslog/syslog.test
index 9818e26cb..0efd7e3ed 100644
--- a/modules/syslog/syslog.test
+++ b/modules/syslog/syslog.test
@@ -22,20 +22,16 @@ class SyslogTestCase extends DrupalWebTestCase {
$this->drupalLogin($admin_user);
$edit = array();
- // If we're on Windows, LOG_LOCAL6 will not be available.
+ // If we're on Windows, there is no configuration form.
if (defined('LOG_LOCAL6')) {
- $edit['syslog_facility'] = LOG_LOCAL6;
- }
- else {
- $edit['syslog_facility'] = LOG_USER;
- }
- $this->drupalPost('admin/config/development/logging', $edit, t('Save configuration'));
- $this->assertText(t('The configuration options have been saved.'));
-
- $this->drupalGet('admin/config/development/logging');
- if ($this->parse()) {
- $field = $this->xpath('//option[@value="' . $edit['syslog_facility'] . '"]'); // Should be one field.
- $this->assertTrue($field[0]['selected'] == 'selected', t('Facility value saved.'));
+ $this->drupalPost('admin/config/development/logging', array('syslog_facility' => LOG_LOCAL6), t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'));
+
+ $this->drupalGet('admin/config/development/logging');
+ if ($this->parse()) {
+ $field = $this->xpath('//option[@value="' . LOG_LOCAL6 . '"]'); // Should be one field.
+ $this->assertTrue($field[0]['selected'] == 'selected', t('Facility value saved.'));
+ }
}
}
}