You are here

public function LogStdoutConfigForm::buildForm in log_stdout 8

Same name and namespace in other branches
  1. 8.2 src/Form/LogStdoutConfigForm.php \Drupal\log_stdout\Form\LogStdoutConfigForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/LogStdoutConfigForm.php, line 23

Class

LogStdoutConfigForm
Provides a settings form for stdout logging.

Namespace

Drupal\log_stdout\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Form constructor.
  $form = parent::buildForm($form, $form_state);

  // Default settings.
  $config = $this
    ->config('log_stdout.settings');
  $form['use_stderr'] = [
    '#title' => $this
      ->t('Write warning and error messages to stderr'),
    '#type' => 'radios',
    '#default_value' => $config
      ->get('use_stderr'),
    '#options' => [
      '0' => $this
        ->t('No'),
      '1' => $this
        ->t('Yes'),
    ],
  ];
  $form['format'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Log format'),
    '#default_value' => $config
      ->get('format'),
    '#description' => $this
      ->t("Specify the format of the log entry. Available variables are: <dl>\n        <dt><code>@base_url</code></dt><dd>Base URL of the site.</dd>\n        <dt><code>@timestamp</code></dt><dd>Unix timestamp of the log entry.</dd>\n        <dt><code>@type</code></dt><dd>The category to which this message belongs.</dd>\n        <dt><code>@ip</code></dt><dd>IP address of the user triggering the message.</dd>\n        <dt><code>@request_uri</code></dt><dd>The requested URI.</dd>\n        <dt><code>@referer</code></dt><dd>HTTP Referer if available.</dd>\n        <dt><code>@severity</code></dt><dd>The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).</dd>\n        <dt><code>@uid</code></dt><dd>User ID.</dd>\n        <dt><code>@link</code></dt><dd>A link to associate with the message.</dd>\n        <dt><code>@message</code></dt><dd>The message to store in the log.</dd></dl>"),
  ];
  return $form;
}