Commit d07be344 authored by Marcin Haba's avatar Marcin Haba
Browse files

baculum: Add option to enable/disable audit log

parent e654a550
......@@ -688,3 +688,6 @@ msgstr "Configs:"
msgid "Dedicated Bconsole config"
msgstr "Dedicated Bconsole config"
msgid "Audit log:"
msgstr "Audit log:"
......@@ -694,3 +694,6 @@ msgstr "Pliki konfig.:"
msgid "Dedicated Bconsole config"
msgstr "Dedykowana konfiguracja Bconsole"
msgid "Audit log:"
msgstr "Audit log:"
......@@ -695,3 +695,6 @@ msgstr "Configurações:"
msgid "Dedicated Bconsole config"
msgstr "Configuração do Bconsole dedicado"
msgid "Audit log:"
msgstr "Audit log:"
......@@ -695,3 +695,6 @@ msgstr "Настройка:"
msgid "Dedicated Bconsole config"
msgstr "Выделенная Bconsole"
msgid "Audit log:"
msgstr "Audit log:"
......@@ -173,6 +173,7 @@ abstract class BaculumAPIServer extends TPage {
$config = $this->getModule('api_config')->getConfig('api');
Logging::$audit_enabled = (!key_exists('audit_log', $config) || $config['audit_log'] == 1);
Logging::$debug_enabled = (key_exists('debug', $config) && $config['debug'] == 1);
if ($this->authenticate() === false) {
......
......@@ -31,6 +31,15 @@
</com:TActiveDropDownList>
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col w3-quarter"><com:TLabel ForControl="GeneralAuditLog" Text="<%[ Audit log: ]%>" /></div>
<div class="w3-col w3-threequarter">
<com:TActiveCheckBox
ID="GeneralAuditLog"
CssClass="w3-check"
/>
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col w3-quarter"><com:TLabel ForControl="GeneralDebug" Text="<%[ Debug: ]%>" /></div>
<div class="w3-col w3-threequarter">
......
......@@ -64,6 +64,8 @@ class APISettings extends BaculumAPIPage {
return;
}
$this->GeneralLang->SelectedValue= $this->config['api']['lang'];
// NOTE: Default audit log is enabled
$this->GeneralAuditLog->Checked = (!key_exists('audit_log', $this->config['api']) || $this->config['api']['audit_log'] == 1);
$this->GeneralDebug->Checked = ($this->config['api']['debug'] == 1);
}
......@@ -393,6 +395,7 @@ class APISettings extends BaculumAPIPage {
$reload_page = true;
}
$this->config['api']['lang'] = $this->GeneralLang->SelectedValue;
$this->config['api']['audit_log'] = $this->GeneralAuditLog->Checked ? 1 : 0;
$this->config['api']['debug'] = $this->GeneralDebug->Checked ? 1 : 0;
$this->getModule('api_config')->setConfig($this->config);
if ($reload_page) {
......
......@@ -41,6 +41,14 @@ class Logging extends CommonModule {
*/
public static $debug_enabled = false;
/*
* Stores audit enable state.
* Default audit log is enabled.
*
* @var bool
*/
public static $audit_enabled = true;
/**
* Log categories.
*/
......@@ -72,7 +80,7 @@ class Logging extends CommonModule {
*/
private function isEnabled($category) {
$is_enabled = false;
if (self::$debug_enabled === true || $category === self::CATEGORY_AUDIT) {
if ((self::$debug_enabled === true && $category !== self::CATEGORY_AUDIT) || (self::$audit_enabled === true && $category === self::CATEGORY_AUDIT)) {
// NOTE: Audit log is written always, it is not possible to disable it
$is_enabled = true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment