' . t('About') . ''; $output .= '

' . t("The Syslog module logs events by sending messages to the logging facility of your web server's operating system. Syslog is an operating system administrative logging tool that 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. For more information, see the online handbook entry for Syslog module and PHP's openlog and syslog functions.", array('@syslog' => 'http://drupal.org/documentation/modules/syslog', '@php_openlog' => 'http://www.php.net/manual/function.openlog.php', '@php_syslog' => 'http://www.php.net/manual/function.syslog.php')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Logging for UNIX, Linux, and Mac OS X') . '
'; $output .= '
' . t('On UNIX, Linux, and Mac OS X, the file /etc/syslog.conf defines the routing configuration. Messages can be flagged with the codes LOG_LOCAL0 through LOG_LOCAL7. For information on Syslog facilities, severity levels, and how to set up syslog.conf, see the syslog.conf manual page on your command line.') . '
'; $output .= '
' . t('Logging for Microsoft Windows') . '
'; $output .= '
' . t('On Microsoft Windows, messages are always sent to the Event Log using the code LOG_USER.') . '
'; $output .= '
'; return $output; } } /** * Implements hook_form_FORM_ID_alter(). */ function syslog_form_system_logging_settings_alter(&$form, &$form_state) { $help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL; $form['syslog_identity'] = array( '#type' => 'textfield', '#title' => t('Syslog identity'), '#default_value' => variable_get('syslog_identity', 'drupal'), '#description' => t('A string that will be prepended to every message logged to Syslog. If you have multiple sites logging to the same Syslog log file, a unique identity per site makes it easy to tell the log entries apart.') . $help, ); if (defined('LOG_LOCAL0')) { $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['syslog_format'] = array( '#type' => 'textarea', '#title' => t('Syslog format'), '#default_value' => variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), '#description' => t('Specify the format of the syslog entry. Available variables are:
!base_url
Base URL of the site.
!timestamp
Unix timestamp of the log entry.
!type
The category to which this message belongs.
!ip
IP address of the user triggering the message.
!request_uri
The requested URI.
!referer
HTTP Referer if available.
!uid
User ID.
!link
A link to associate with the message.
!message
The message to store in the log.
'), ); $form['actions']['#weight'] = 1; } /** * Lists all possible syslog facilities for UNIX/Linux. * * @return array * An array of syslog facilities for UNIX/Linux. */ function syslog_facility_list() { 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', ); } /** * Implements hook_watchdog(). */ function syslog_watchdog(array $log_entry) { global $base_url; $log_init = &drupal_static(__FUNCTION__, FALSE); if (!$log_init) { $log_init = TRUE; $default_facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER; openlog(variable_get('syslog_identity', 'drupal'), LOG_NDELAY, variable_get('syslog_facility', $default_facility)); } $message = strtr(variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), array( '!base_url' => $base_url, '!timestamp' => $log_entry['timestamp'], '!type' => $log_entry['type'], '!ip' => $log_entry['ip'], '!request_uri' => $log_entry['request_uri'], '!referer' => $log_entry['referer'], '!uid' => $log_entry['uid'], '!link' => strip_tags($log_entry['link']), '!message' => strip_tags(!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])), )); syslog($log_entry['severity'], $message); }