' . 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 documentation for the Syslog module, as well as PHP\'s documentation pages for the openlog and syslog functions.', [':syslog' => 'https://www.drupal.org/documentation/modules/syslog']) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Logging for UNIX, Linux, and Mac OS X') . '
'; $output .= '
' . t('On UNIX, Linux, and Mac OS X, you will find the configuration in the file /etc/syslog.conf, or in /etc/rsyslog.conf or in the directory /etc/rsyslog.d. These files define 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 or rsyslog.conf, see the syslog.conf or rsyslog.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, FormStateInterface $form_state) { $config = \Drupal::configFactory()->getEditable('syslog.settings'); $help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . Link::fromTextAndUrl(t('More information'), Url::fromRoute('help.page', ['name' => 'syslog']))->toString() . '.' : NULL; $form['syslog_identity'] = [ '#type' => 'textfield', '#title' => t('Syslog identity'), '#default_value' => $config->get('identity'), '#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'] = [ '#type' => 'select', '#title' => t('Syslog facility'), '#default_value' => $config->get('facility'), '#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'] = [ '#type' => 'textarea', '#title' => t('Syslog format'), '#default_value' => $config->get('format'), '#required' => TRUE, '#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.
!severity
The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).
!uid
User ID.
!link
A link to associate with the message.
!message
The message to store in the log.
'), ]; $form['#submit'][] = 'syslog_logging_settings_submit'; } /** * Form submission handler for system_logging_settings(). * * @see syslog_form_system_logging_settings_alter() */ function syslog_logging_settings_submit($form, FormStateInterface $form_state) { \Drupal::configFactory()->getEditable('syslog.settings') ->set('identity', $form_state->getValue('syslog_identity')) ->set('facility', $form_state->getValue('syslog_facility')) ->set('format', $form_state->getValue('syslog_format')) ->save(); } /** * Lists all possible syslog facilities for UNIX/Linux. * * @return array * An array of syslog facilities for UNIX/Linux. */ function syslog_facility_list() { return [ 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', ]; }