Automatically generated installer lang files
[moodle.git] / admin / tasklogs.php
blob046aaafdcfb4ae02d1cdd707a997728359da2d93
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Task log.
20 * @package admin
21 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require_once(__DIR__ . '/../config.php');
26 require_once("{$CFG->libdir}/adminlib.php");
28 use core_admin\local\systemreports\task_logs;
29 use core_reportbuilder\system_report_factory;
31 $PAGE->set_url(new \moodle_url('/admin/tasklogs.php'));
32 $PAGE->set_context(context_system::instance());
33 $PAGE->set_pagelayout('admin');
34 $strheading = get_string('tasklogs', 'admin');
35 $PAGE->set_title($strheading);
36 $PAGE->set_heading($strheading);
38 admin_externalpage_setup('tasklogs');
40 $logid = optional_param('logid', null, PARAM_INT);
41 $download = optional_param('download', false, PARAM_BOOL);
42 $filter = optional_param('filter', null, PARAM_TEXT);
44 if (null !== $logid) {
45 // Raise memory limit in case the log is large.
46 raise_memory_limit(MEMORY_HUGE);
47 $log = $DB->get_record('task_log', ['id' => $logid], '*', MUST_EXIST);
49 if ($download) {
50 $filename = str_replace('\\', '_', $log->classname) . "-{$log->id}.log";
51 header("Content-Disposition: attachment; filename=\"{$filename}\"");
54 readstring_accel($log->output, 'text/plain');
55 exit;
58 echo $OUTPUT->header();
59 $report = system_report_factory::create(task_logs::class, context_system::instance());
61 if (!empty($filter)) {
62 $report->set_filter_values([
63 'task_log:name_operator' => \core_reportbuilder\local\filters\text::IS_EQUAL_TO,
64 'task_log:name_value' => $filter,
65 ]);
68 echo $report->output();
69 echo $OUTPUT->footer();