diff --git a/modules/syslog/syslog.module b/modules/syslog/syslog.module index ad2929dc480..5768701f006 100644 --- a/modules/syslog/syslog.module +++ b/modules/syslog/syslog.module @@ -52,6 +52,13 @@ function syslog_admin_settings() { '#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 Syslog help.', array( '@syslog_help' => url('admin/help/syslog'))), ); + + $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.
'), + ); return system_settings_form($form); } @@ -74,7 +81,8 @@ function syslog_facility_list() { return $facility_list; } -function syslog_watchdog($entry) { +function syslog_watchdog(array $log_entry) { + global $base_url; static $log_init = FALSE; if (!$log_init) { @@ -82,34 +90,17 @@ function syslog_watchdog($entry) { openlog(variable_get('syslog_identity', 'drupal'), LOG_NDELAY, variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY)); } - syslog($entry['severity'], theme('syslog_format', $entry)); -} - -function syslog_theme() { - return array( - 'syslog_format' => array( - 'arguments' => array('entry' => NULL), - ), - ); -} + $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['user']->uid, + '!link' => strip_tags($log_entry['link']), + '!message' => strip_tags(is_null($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])), + )); -/** - * Format a system log entry. - * - * @ingroup themeable - */ -function theme_syslog_format($entry) { - global $base_url; - - $message = $base_url; - $message .= '|'. $entry['timestamp']; - $message .= '|'. $entry['type']; - $message .= '|'. $entry['ip']; - $message .= '|'. $entry['request_uri']; - $message .= '|'. $entry['referer']; - $message .= '|'. $entry['user']->uid; - $message .= '|'. strip_tags($entry['link']); - $message .= '|'. strip_tags(is_null($entry['variables']) ? $entry['message'] : strtr($entry['message'], $entry['variables'])); - - return $message; -} + syslog($log_entry['severity'], $message); +} \ No newline at end of file