MDL-41269 add standard log life time and add missing lang strings

This commit is contained in:
Petr Škoda 2014-01-30 15:12:36 +08:00
parent ae0770513f
commit 30e55e9ac6
4 changed files with 41 additions and 5 deletions

View File

@ -40,6 +40,11 @@ class store implements \tool_log\log\writer, \core\log\sql_reader {
$this->logguests = $this->get_config('logguests', 1);
}
/**
* Finally store the events into the database.
*
* @param \core\event\base[] $events
*/
protected function insert_events($events) {
global $DB;
@ -102,5 +107,15 @@ class store implements \tool_log\log\writer, \core\log\sql_reader {
}
public function cron() {
global $DB;
$loglifetime = $this->get_config('loglifetime', 0);
// NOTE: we should do this only once a day, new cron will deal with this.
if ($loglifetime > 0) {
$loglifetime = time() - ($loglifetime * 3600 * 24); // Value in days.
$DB->delete_records_select("logstore_standard_log", "timecreated < ?", array($loglifetime));
mtrace(" Deleted old log records from standard store.");
}
}
}

View File

@ -22,6 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['buffersize'] = 'Write buffer size';
$string['pluginname'] = 'Standard log';
$string['pluginname_desc'] = 'Standard log plugin, the data is stored in Moodle database table.';
$string['standard:read'] = 'Read logs';

View File

@ -26,8 +26,28 @@ defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig) {
// TODO: Localise these settings.
$settings->add(new admin_setting_configcheckbox('logstore_standard/logguests',
new lang_string('logguests', 'core_admin'),
new lang_string('logguests_help', 'core_admin'), 1));
$settings->add(new admin_setting_configcheckbox('logstore_standard/logguests', 'Log guest actions', '', '1'));
$settings->add(new admin_setting_configtext('logstore_standard/buffersize', 'Buffer size', '', '50', PARAM_INT));
$options = array(
0 => new lang_string('neverdeletelogs'),
1000 => new lang_string('numdays', '', 1000),
365 => new lang_string('numdays', '', 365),
180 => new lang_string('numdays', '', 180),
150 => new lang_string('numdays', '', 150),
120 => new lang_string('numdays', '', 120),
90 => new lang_string('numdays', '', 90),
60 => new lang_string('numdays', '', 60),
35 => new lang_string('numdays', '', 35),
10 => new lang_string('numdays', '', 10),
5 => new lang_string('numdays', '', 5),
2 => new lang_string('numdays', '', 2));
$settings->add(new admin_setting_configselect('logstore_standard/loglifetime',
new lang_string('loglifetime', 'core_admin'),
new lang_string('configloglifetime', 'core_admin'), 0, $options));
$settings->add(new admin_setting_configtext('logstore_standard/buffersize',
get_string('buffersize', 'logstore_standard'),
'', '50', PARAM_INT));
}

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014011300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014011000; // Requires this Moodle version.
$plugin->version = 2014013000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014012400; // Requires this Moodle version.
$plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics).