1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<?php
/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Audit\Forms\Config;
use Icinga\Forms\ConfigForm;
class AuditLogConfigForm extends ConfigForm
{
public function createElements(array $formData)
{
$this->addElement(
'select',
'log_type',
[
'autosubmit' => true,
'label' => $this->translate('Standard Log'),
'description' => $this->translate('Human-readable message log'),
'multiOptions' => [
'none' => $this->translate('None', 'log.type'),
'file' => $this->translate('File'),
'syslog' => 'Syslog'
]
]
);
if (isset($formData['log_type']) && $formData['log_type'] === 'file') {
$this->addElement(
'text',
'log_path',
[
'label' => $this->translate('Standard Log Path'),
'description' => $this->translate('The full path to the standard log'),
'placeholder' => '/var/log/icingaweb2/audit.log'
]
);
} elseif (isset($formData['log_type']) && $formData['log_type'] === 'syslog') {
$this->addElement(
'text',
'log_ident',
[
'label' => $this->translate('Ident'),
'description' => $this->translate('The identifier to use for syslog messages'),
'placeholder' => 'icingaweb2-audit'
]
);
$this->addElement(
'select',
'log_facility',
[
'label' => $this->translate('Facility'),
'description' => $this->translate('The facility to send syslog messages to'),
'multiOptions' => [
'' => 'auth', // The default
'authpriv' => 'authpriv',
'user' => 'user',
'local0' => 'local0',
'local1' => 'local1',
'local2' => 'local2',
'local3' => 'local3',
'local4' => 'local4',
'local5' => 'local5',
'local6' => 'local6',
'local7' => 'local7'
]
]
);
}
$this->addElement(
'checkbox',
'stream_format',
[
'autosubmit' => true,
'label' => $this->translate('JSON Log'),
'description' => $this->translate('Machine-parsable JSON objects'),
'checkedValue' => 'json',
'uncheckedValue' => 'none'
]
);
if (isset($formData['stream_format']) && $formData['stream_format'] === 'json') {
$this->addElement(
'text',
'stream_path',
[
'label' => $this->translate('JSON Log Path'),
'description' => $this->translate('The full path to the JSON log'),
'placeholder' => '/var/log/icingaweb2/audit.json'
]
);
}
}
}
|