Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803921
D466.id1279.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:01 AM
Size
21 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:01 AM (7 h, 48 m)
Engine
blob
Format
Raw Data
Handle
576641
Attached To
D466: INP-1854 - Create global switch for Web Request/Session Data logging into the System Log
D466.id1279.diff
View Options
Index: core/install/english.lang
===================================================================
--- core/install/english.lang
+++ core/install/english.lang
@@ -215,6 +215,7 @@
<PHRASE Label="la_config_StickyGridSelection" Module="Core" Type="1">VXNlIFN0aWNreSBHcmlkIFNlbGVjdGlvbg==</PHRASE>
<PHRASE Label="la_config_SystemLogCodeFragmentPathFilterRegExp" Module="Core" Type="1">UmVjb3JkIGNvZGUgZnJhZ21lbnRzIGluICJTeXN0ZW0gTG9nIiBmb3IgdGhlc2UgcGF0aHMgKHJlZ2V4cCk=</PHRASE>
<PHRASE Label="la_config_SystemLogNotificationEmail" Module="Core" Type="1" Hint="RW1haWwgYWRkcmVzcyB3aGVyZSBVc2VyLWRlZmluZWQgbWVzc2FnZXMgKG1hbnVhbGx5IHNldHVwIGluIHRoZSBjb2RlKSB3aWxsIGJlIGVtYWlsZWQgdG8uIE5vdGUgdGhhdCBhbGwgZGVmYXVsdCAiU3lzdGVtIExvZyIgbWVzc2FnZXMgKG5vbmUgdXNlci1kZWZpbmVkKSBhcmUgTk9UIGVtYWlsZWQgYnkgZGVmYXVsdC4=">U2VuZCBVc2VyLWRlZmluZWQgIlN5c3RlbSBMb2ciIG1lc3NhZ2VzIHRv</PHRASE>
+ <PHRASE Label="la_config_SystemLogRequestDataRotationInterval" Module="Core" Type="1" Hint="VGhpcyBzZXR0aW5nIGFsbG93cyB5b3UgdG8gY29udHJvbCBmb3IgaG93IGxvbmcgcmVxdWVzdCBkYXRhIGluICJTeXN0ZW0gTG9nIiBtZXNzYWdlcyB3aWxsIGJlIHN0b3JlZCBpbiB0aGUgbG9nIGFuZCB0aGVuIGF1dG9tYXRpY2FsbHkgZGVsZXRlZC4gVXNlIG9wdGlvbiAiRm9yZXZlciIgd2l0aCBjYXV0aW9uIHNpbmNlIGl0IHdpbGwgY29tcGxldGVseSBkaXNhYmxlIGF1dG9tYXRpYyByZXF1ZXN0IGRhdGEgY2xlYW51cCBhbmQgY2FuIGxlYWQgdG8gbGFyZ2Ugc2l6ZSBvZiBkYXRhYmFzZSB0YWJsZSB0aGF0IHN0b3JlcyBsb2cgbWVzc2FnZXMu">S2VlcCBSZXF1ZXN0IERhdGEgaW4gIlN5c3RlbSBMb2ciIGZvcg==</PHRASE>
<PHRASE Label="la_config_SystemLogRotationInterval" Module="Core" Type="1" Hint="VGhpcyBzZXR0aW5nIGFsbG93cyB5b3UgdG8gY29udHJvbCBmb3IgaG93IGxvbmcgIlN5c3RlbSBMb2ciIG1lc3NhZ2VzIHdpbGwgYmUgc3RvcmVkIGluIHRoZSBsb2cgYW5kIHRoZW4gYXV0b21hdGljYWxseSBkZWxldGVkLiBVc2Ugb3B0aW9uICJGb3JldmVyIiB3aXRoIGNhdXRpb24gc2luY2UgaXQgd2lsbCBjb21wbGV0ZWx5IGRpc2FibGUgYXV0b21hdGljIGxvZyBjbGVhbnVwIGFuZCBjYW4gbGVhZCB0byBsYXJnZSBzaXplIG9mIGRhdGFiYXNlIHRhYmxlIHRoYXQgc3RvcmVzIGxvZyBtZXNzYWdlcy4=">S2VlcCAiU3lzdGVtIExvZyIgZm9y</PHRASE>
<PHRASE Label="la_config_ThumbnailImageHeight" Module="Core" Type="1">VGh1bWJuYWlsIEhlaWdodA==</PHRASE>
<PHRASE Label="la_config_ThumbnailImageWidth" Module="Core" Type="1">VGh1bWJuYWlsIFdpZHRo</PHRASE>
Index: core/install/install_data.sql
===================================================================
--- core/install/install_data.sql
+++ core/install/install_data.sql
@@ -104,8 +104,9 @@
INSERT INTO SystemSettings VALUES(DEFAULT, 'EnableEmailLog', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_EnableEmailLog', 'radio', NULL, '1=la_Yes||0=la_No', 65.01, 0, 1, 'hint:la_config_EnableEmailLog');
INSERT INTO SystemSettings VALUES(DEFAULT, 'EmailLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_EmailLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_EmailLogKeepForever', 65.02, 0, 0, 'hint:la_config_EmailLogRotationInterval');
INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.03, 0, 1, 'hint:la_config_SystemLogRotationInterval');
-INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogNotificationEmail', '', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogNotificationEmail', 'text', 'a:5:{s:4:"type";s:6:"string";s:9:"formatter";s:10:"kFormatter";s:6:"regexp";s:85:"/^([-a-zA-Z0-9!\\#$%&*+\\/=?^_`{|}~.]+@[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\\.[a-zA-Z]{2,6})$/i";s:10:"error_msgs";a:1:{s:14:"invalid_format";s:18:"!la_invalid_email!";}s:7:"default";s:0:"";}', NULL, 65.04, 0, 1, 'hint:la_config_SystemLogNotificationEmail');
-INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogCodeFragmentPathFilterRegExp', '#(modules/custom|system/cache/modules/custom)/.*#', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogCodeFragmentPathFilterRegExp', 'text', NULL, NULL, 65.05, 0, 1, NULL);
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogRequestDataRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRequestDataRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.04, 0, 1, 'hint:la_config_SystemLogRequestDataRotationInterval');
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogNotificationEmail', '', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogNotificationEmail', 'text', 'a:5:{s:4:"type";s:6:"string";s:9:"formatter";s:10:"kFormatter";s:6:"regexp";s:85:"/^([-a-zA-Z0-9!\\#$%&*+\\/=?^_`{|}~.]+@[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\\.[a-zA-Z]{2,6})$/i";s:10:"error_msgs";a:1:{s:14:"invalid_format";s:18:"!la_invalid_email!";}s:7:"default";s:0:"";}', NULL, 65.05, 0, 1, 'hint:la_config_SystemLogNotificationEmail');
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogCodeFragmentPathFilterRegExp', '#(modules/custom|system/cache/modules/custom)/.*#', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogCodeFragmentPathFilterRegExp', 'text', NULL, NULL, 65.06, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportDelimiter', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportDelimiter', 'select', NULL, '0=la_opt_Tab||1=la_opt_Comma||2=la_opt_Semicolon||3=la_opt_Space||4=la_opt_Colon', 70.01, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportEnclosure', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportEnclosure', 'radio', NULL, '0=la_Doublequotes||1=la_Quotes', 70.02, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportSeparator', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportSeparator', 'radio', NULL, '0=la_Linux||1=la_Windows', 70.03, 0, 1, NULL);
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql
+++ core/install/install_schema.sql
@@ -441,6 +441,7 @@
LogRequestSource tinyint(4) DEFAULT NULL,
LogRequestURI varchar(255) NOT NULL DEFAULT '',
LogRequestData longtext,
+ LogRequestDataRotated tinyint(4) NOT NULL DEFAULT '0',
LogUserId int(11) DEFAULT NULL,
LogInterface tinyint(4) DEFAULT NULL,
IpAddress varchar(15) NOT NULL DEFAULT '',
@@ -459,7 +460,8 @@
KEY LogLevel (LogLevel),
KEY LogType (LogType),
KEY LogNotificationStatus (LogNotificationStatus),
- KEY `TIMESTAMP_CODE_FRAGMENTS_ROTATED` (`LogTimestamp`,`LogCodeFragmentsRotated`) USING BTREE
+ KEY `TIMESTAMP_CODE_FRAGMENTS_ROTATED` (`LogTimestamp`,`LogCodeFragmentsRotated`) USING BTREE,
+ KEY `TIMESTAMP_REQUEST_DATA_ROTATED` (`LogTimestamp`,`LogRequestDataRotated`) USING BTREE
);
CREATE TABLE SystemCache (
Index: core/install/step_templates/sys_config.tpl
===================================================================
--- core/install/step_templates/sys_config.tpl
+++ core/install/step_templates/sys_config.tpl
@@ -14,12 +14,15 @@
'WebsiteCharset' => Array ('type' => 'text', 'title' => 'Website Charset', 'section' => 'Misc', 'required' => 1),
'EnableSystemLog' => Array ('type' => 'radio', 'title' => 'Enable "System Log"', 'section' => 'Misc', 'required' => 1),
'SystemLogMaxLevel' => Array ('type' => 'select', 'title' => 'Highest "Log Level", that will be saved in "System Log"', 'section' => 'Misc', 'required' => 1),
+ 'SystemLogIncludeRequestData' => Array ('type' => 'radio', 'title' => 'Include Web Request data in "System Log"', 'section' => 'Misc', 'required' => 1),
+ 'SystemLogRequestDataLimit' => Array ('type' => 'text', 'title' => 'Largest Web Request/Session Size, that will be saved in "System Log"', 'section' => 'Misc', 'required' => 1),
'TrustProxy' => Array ('type' => 'radio', 'title' => 'Trust Proxy', 'section' => 'Misc', 'required' => 1),
);
$settings['CacheHandler']['options'] = $this->toolkit->getWorkingCacheHandlers();
$settings['CompressionEngine']['options'] = $this->toolkit->getWorkingCompressionEngines();
$settings['EnableSystemLog']['options'] = Array (1 => 'Enabled', 2 => 'User-only', 0 => 'Disabled');
+ $settings['SystemLogIncludeRequestData']['options'] = Array (1 => 'Yes', 0 => 'No');
$settings['SystemLogMaxLevel']['options'] = Array (
0 => 'emergency', 1 => 'alert', 2 => 'critical', 3 => 'error',
4 => 'warning', 5 => 'notice', 6 => 'info', 7 => 'debug'
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql
+++ core/install/upgrades.sql
@@ -2986,3 +2986,10 @@
UPDATE UserSessionLogs SET SessionKey = SessionId;
ALTER TABLE CurlLog CHANGE `SessionKey` `SessionKey` char(64) NOT NULL DEFAULT '';
ALTER TABLE SystemLog CHANGE `LogSessionKey` `LogSessionKey` char(64) NOT NULL DEFAULT '';
+
+UPDATE SystemSettings
+SET DisplayOrder = ROUND(DisplayOrder + 0.01, 2)
+WHERE ModuleOwner = 'In-Portal' AND Section = 'in-portal:configure_advanced' AND DisplayOrder > 65.03 AND DisplayOrder < 66;
+INSERT INTO SystemSettings VALUES (DEFAULT, 'SystemLogRequestDataRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRequestDataRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.04, 0, 1, 'hint:la_config_SystemLogRequestDataRotationInterval');
+ALTER TABLE SystemLog ADD COLUMN `LogRequestDataRotated` tinyint NOT NULL DEFAULT '0' AFTER `LogRequestData`;
+ALTER TABLE SystemLog ADD INDEX `TIMESTAMP_REQUEST_DATA_ROTATED` (`LogTimestamp`,`LogRequestDataRotated`) USING BTREE;
Index: core/kernel/utility/logger.php
===================================================================
--- core/kernel/utility/logger.php
+++ core/kernel/utility/logger.php
@@ -173,6 +173,20 @@
protected static $_longMessages = Array ();
/**
+ * Require addition of the request data to the upcoming log record.
+ *
+ * @var boolean|null
+ */
+ protected $requestDataRequired;
+
+ /**
+ * Require addition of the session data to the upcoming log record.
+ *
+ * @var boolean|null
+ */
+ protected $sessionDataRequired;
+
+ /**
* Log record being worked on
*
* @var Array
@@ -181,6 +195,20 @@
protected $_logRecord = Array ();
/**
+ * Include request data in the upcoming record.
+ *
+ * @var boolean
+ */
+ protected $includeRequestData = false;
+
+ /**
+ * Web request (or session) data limit in bytes.
+ *
+ * @var integer
+ */
+ protected $requestDataLimit;
+
+ /**
* Maximal level of a message, that can be logged
*
* @var int
@@ -236,6 +264,12 @@
$this->setState($system_config->get('EnableSystemLog', self::STATE_DISABLED));
$this->_maxLogLevel = $system_config->get('SystemLogMaxLevel', self::LL_NOTICE);
+ if ( PHP_SAPI !== 'cli' ) {
+ $this->includeRequestData = (boolean)$system_config->get('SystemLogIncludeRequestData', '1');
+ }
+
+ $this->requestDataLimit = kUtil::parseIniSize($system_config->get('SystemLogRequestDataLimit', '5MB'));
+
foreach ($methods_to_call as $method_to_call) {
call_user_func_array(Array ($this, $method_to_call[0]), $method_to_call[1]);
}
@@ -343,6 +377,15 @@
'LogNotificationStatus' => self::LNS_DISABLED,
);
+ if ( $this->includeRequestData ) {
+ $this->requestDataRequired = true;
+ $this->sessionDataRequired = false; // The "false" means, that optional data needs to be excluded.
+ }
+ else {
+ $this->requestDataRequired = null;
+ $this->sessionDataRequired = null;
+ }
+
if ( $this->Application->isAdmin ) {
$this->_logRecord['LogInterface'] = defined('CRON') && CRON ? self::LI_CRON_ADMIN : self::LI_ADMIN;
}
@@ -471,29 +514,80 @@
}
/**
- * Adds session contents to log record
+ * Adds session contents to the log record upon its creation.
*
- * @param bool $include_optional Include optional session variables
- * @return kLogger
- * @access public
+ * @param boolean $include_optional Include optional session variables.
+ *
+ * @return static
*/
public function addSessionData($include_optional = false)
{
+ $this->sessionDataRequired = $include_optional;
+
+ return $this;
+ }
+
+ /**
+ * Removes session contents from the log record.
+ *
+ * @return static
+ */
+ public function removeSessionData()
+ {
+ $this->sessionDataRequired = null;
+
+ return $this;
+ }
+
+ /**
+ * Adds session contents to log record.
+ *
+ * @param boolean $include_optional Include optional session variables.
+ *
+ * @return static
+ */
+ protected function doAddSessionData($include_optional = false)
+ {
if ( $this->Application->InitDone ) {
- $this->_logRecord['LogSessionData'] = serialize($this->Application->Session->getSessionData($include_optional));
+ $this->_logRecord['LogSessionData'] = $this->prepareRequestDataForDatabase(
+ $this->Application->Session->getSessionData($include_optional)
+ );
}
return $this;
}
/**
- * Adds user request information to log record
+ * Adds web request data to the log record upon its creation.
*
- * @return kLogger
- * @access public
+ * @return static
*/
public function addRequestData()
{
+ $this->requestDataRequired = true;
+
+ return $this;
+ }
+
+ /**
+ * Removes web request data from the log record.
+ *
+ * @return static
+ */
+ public function removeRequestData()
+ {
+ $this->requestDataRequired = false;
+
+ return $this;
+ }
+
+ /**
+ * Adds user request information to log record.
+ *
+ * @return static
+ */
+ protected function doAddRequestData()
+ {
$request_data = array(
'Headers' => $this->Application->HttpQuery->getHeaders(),
);
@@ -508,12 +602,64 @@
$request_data[$title] = $data;
}
- $this->_logRecord['LogRequestData'] = serialize($request_data);
+ $this->_logRecord['LogRequestData'] = $this->prepareRequestDataForDatabase($request_data);
return $this;
}
/**
+ * Prepares request data for storing in the database.
+ *
+ * @param array $request_data Request data.
+ *
+ * @return string
+ */
+ protected function prepareRequestDataForDatabase(array $request_data)
+ {
+ if ( !$request_data ) {
+ return serialize(array());
+ }
+
+ $reduced_request_data = $request_data;
+ $request_data_element_count = $reduced_request_data_element_count = count($request_data);
+
+ do {
+ $prepared_reduced_data = serialize($reduced_request_data);
+ $prepared_reduced_data_length = strlen($prepared_reduced_data);
+
+ if ( $prepared_reduced_data_length < $this->requestDataLimit ) {
+ // Given data is already within a limits.
+ if ( $reduced_request_data_element_count == $request_data_element_count ) {
+ return $prepared_reduced_data;
+ }
+
+ // Data was reduced.
+ break;
+ }
+
+ // Account for case, when limit is smaller than 6 bytes (size of an empty serialized array).
+ if ( $reduced_request_data_element_count === 0 ) {
+ break;
+ }
+
+ // Reduce request data by 1 element at a time until it fits the limit.
+ array_pop($reduced_request_data);
+ $reduced_request_data_element_count--;
+ } while ( true );
+
+ $error_msg = sprintf(
+ 'The %d bytes (%d elements) of data not logged, because it is larger, than %d bytes limit.',
+ strlen(serialize($request_data)) - $prepared_reduced_data_length,
+ $request_data_element_count - $reduced_request_data_element_count,
+ $this->requestDataLimit
+ );
+
+ $reduced_request_data['system-log-error'] = $error_msg;
+
+ return serialize($reduced_request_data);
+ }
+
+ /**
* Adds trace to log record
*
* @param Array $trace
@@ -858,6 +1004,14 @@
return false;
}
+ if ( $this->requestDataRequired === true ) {
+ $this->doAddRequestData();
+ }
+
+ if ( $this->sessionDataRequired !== null ) {
+ $this->doAddSessionData($this->sessionDataRequired);
+ }
+
$this->_logRecord['LogMemoryUsed'] = memory_get_usage();
$this->_logRecord['LogTimestamp'] = adodb_mktime();
$this->_logRecord['LogDate'] = adodb_date('Y-m-d H:i:s');
Index: core/kernel/utility/system_config.php
===================================================================
--- core/kernel/utility/system_config.php
+++ core/kernel/utility/system_config.php
@@ -79,6 +79,8 @@
'SectionsParsedRebuildTime' => 5,
'StructureTreeRebuildTime' => 10,
'SystemLogMaxLevel' => 5,
+ 'SystemLogRequestDataLimit' => '5MB',
+ 'SystemLogIncludeRequestData' => '1',
'TemplateMappingRebuildTime' => 5,
'TrustProxy' => '0',
'UnitCacheRebuildTime' => 10,
Index: core/units/logs/system_logs/system_log_eh.php
===================================================================
--- core/units/logs/system_logs/system_log_eh.php
+++ core/units/logs/system_logs/system_log_eh.php
@@ -213,4 +213,81 @@
}
}
+ /**
+ * Removes old request data.
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnRotateRequestDataScheduledTask(kEvent $event)
+ {
+ $rotation_interval = (int)$this->Application->ConfigValue('SystemLogRequestDataRotationInterval');
+
+ // Forever.
+ if ( $rotation_interval === -1 ) {
+ return;
+ }
+
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+
+ $where_clause = array(
+ 'LogTimestamp < ' . strtotime('-' . $rotation_interval . ' seconds'),
+ 'LogRequestDataRotated = 0',
+ );
+
+ $sql = 'SELECT ' . $id_field . '
+ FROM ' . $table_name . '
+ WHERE (' . implode(') AND (', $where_clause) . ')
+ LIMIT 0,500';
+ $records = $this->Conn->GetColIterator($sql, $id_field);
+
+ foreach ( $records as $system_log_id ) {
+ $this->Conn->doUpdate(
+ array(
+ 'LogRequestData' => null,
+ 'LogSessionData' => null,
+ 'LogRequestDataRotated' => 1,
+ ),
+ $table_name,
+ $id_field . ' = ' . $system_log_id
+ );
+ }
+ }
+
+ /**
+ * Ensures, that used system setting values don't collide.
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnBeforeConfigurationValidatedHook(kEvent $event)
+ {
+ /** @var ConfigurationItem $configuration */
+ $configuration = $event->MasterEvent->getObject();
+ $variable_name = $configuration->GetDBField('VariableName');
+
+ if ( $variable_name === 'SystemLogRequestDataRotationInterval' ) {
+ $request_data_rotation_interval = (int)$configuration->GetDBField('VariableValue');
+ $global_rotation_interval = (int)$this->Application->ConfigValue('SystemLogRotationInterval');
+
+ // Not forever.
+ if ( $request_data_rotation_interval !== -1
+ && $global_rotation_interval !== -1
+ && $request_data_rotation_interval > $global_rotation_interval
+ ) {
+ /** @var InpCustomFieldsHelper $custom_fields_helper */
+ $custom_fields_helper = $this->Application->recallObject('InpCustomFieldsHelper');
+ $options = $custom_fields_helper->GetValuesHash($configuration->GetDBField('ValueList'));
+
+ $configuration->SetError('VariableValue', 'value_out_of_range', null, array(
+ 'min_value' => '"' . reset($options) . '"',
+ 'max_value' => '"' . $options[$global_rotation_interval] . '"',
+ ));
+ }
+ }
+ }
+
}
Index: core/units/logs/system_logs/system_logs_config.php
===================================================================
--- core/units/logs/system_logs/system_logs_config.php
+++ core/units/logs/system_logs/system_logs_config.php
@@ -35,6 +35,20 @@
'system_log_notifications' => Array ('EventName' => 'OnSendNotifications', 'RunSchedule' => '0 * * * *'),
'rotate_system_logs' => Array ('EventName' => 'OnRotate', 'RunSchedule' => '0 0 * * *'),
'rotate_system_log_code_fragments' => Array ('EventName' => 'OnRotateCodeFragmentsScheduledTask', 'RunSchedule' => '0 0 * * 0'),
+ 'rotate_system_log_request_data' => Array ('EventName' => 'OnRotateRequestDataScheduledTask', 'RunSchedule' => '0 0 * * 0'),
+ ),
+
+ 'Hooks' => array(
+ array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'conf',
+ 'HookToSpecial' => '',
+ 'HookToEvent' => array('OnBeforeItemValidate'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnBeforeConfigurationValidatedHook',
+ ),
),
'IDField' => 'LogId',
@@ -136,6 +150,12 @@
),
'LogRequestURI' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'LogRequestData' => Array ('type' => 'string', 'default' => NULL),
+ 'LogRequestDataRotated' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter',
+ 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0,
+ ),
'LogUserId' => Array (
'type' => 'int',
'default' => NULL
Index: tools/build/targets/folders.xml
===================================================================
--- tools/build/targets/folders.xml
+++ tools/build/targets/folders.xml
@@ -51,6 +51,8 @@
$_CONFIG['Misc']['WebsiteCharset'] = 'utf-8';
$_CONFIG['Misc']['EnableSystemLog'] = '1';
$_CONFIG['Misc']['SystemLogMaxLevel'] = '5';
+ $_CONFIG['Misc']['SystemLogRequestDataLimit'] = '5MB';
+ $_CONFIG['Misc']['SystemLogIncludeRequestData'] = '1';
$_CONFIG['Misc']['TrustProxy'] = '0';
$_CONFIG['Database']['DBType'] = 'mysql';
Event Timeline
Log In to Comment