mirror of
https://github.com/moodle/moodle.git
synced 2025-08-02 23:59:41 +02:00
MDL-82175 cron: Improved task view logs page
This commit is contained in:
parent
a75365f2e4
commit
340e8b120a
5 changed files with 41 additions and 6 deletions
|
@ -105,9 +105,10 @@ class task_log extends base {
|
||||||
))
|
))
|
||||||
->add_joins($this->get_joins())
|
->add_joins($this->get_joins())
|
||||||
->set_type(column::TYPE_TEXT)
|
->set_type(column::TYPE_TEXT)
|
||||||
->add_field("$tablealias.classname")
|
->add_fields("{$tablealias}.classname, {$tablealias}.id")
|
||||||
->set_is_sortable(true)
|
->set_is_sortable(true)
|
||||||
->add_callback(static function(string $classname): string {
|
->add_callback(static function($value, stdClass $row): string {
|
||||||
|
$classname = $row->classname;
|
||||||
$output = '';
|
$output = '';
|
||||||
if (class_exists($classname)) {
|
if (class_exists($classname)) {
|
||||||
$task = new $classname;
|
$task = new $classname;
|
||||||
|
@ -118,6 +119,7 @@ class task_log extends base {
|
||||||
$output .= \html_writer::tag('div', "\\{$classname}", [
|
$output .= \html_writer::tag('div', "\\{$classname}", [
|
||||||
'class' => 'small text-muted',
|
'class' => 'small text-muted',
|
||||||
]);
|
]);
|
||||||
|
$output = \html_writer::link(new \moodle_url('/admin/tasklogs.php', ['logid' => $row->id]), $output);
|
||||||
return $output;
|
return $output;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ class task_logs extends system_report {
|
||||||
new moodle_url('/admin/tasklogs.php', ['logid' => ':id']),
|
new moodle_url('/admin/tasklogs.php', ['logid' => ':id']),
|
||||||
new pix_icon('e/search', ''),
|
new pix_icon('e/search', ''),
|
||||||
[],
|
[],
|
||||||
true,
|
false,
|
||||||
new lang_string('view'),
|
new lang_string('view'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
require_once(__DIR__ . '/../config.php');
|
require_once(__DIR__ . '/../config.php');
|
||||||
require_once("{$CFG->libdir}/adminlib.php");
|
require_once("{$CFG->libdir}/adminlib.php");
|
||||||
|
require_once("tool/task/lib.php");
|
||||||
|
|
||||||
use core_admin\reportbuilder\local\systemreports\task_logs;
|
use core_admin\reportbuilder\local\systemreports\task_logs;
|
||||||
use core_reportbuilder\system_report_factory;
|
use core_reportbuilder\system_report_factory;
|
||||||
|
@ -49,9 +50,41 @@ if (null !== $logid) {
|
||||||
if ($download) {
|
if ($download) {
|
||||||
$filename = str_replace('\\', '_', $log->classname) . "-{$log->id}.log";
|
$filename = str_replace('\\', '_', $log->classname) . "-{$log->id}.log";
|
||||||
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
||||||
|
readstring_accel($log->output, 'text/plain');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
readstring_accel($log->output, 'text/plain');
|
try {
|
||||||
|
$class = new $log->classname;
|
||||||
|
$title = $class->get_name();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$title = $log->classname;
|
||||||
|
}
|
||||||
|
$title .= " ($log->id)";
|
||||||
|
|
||||||
|
$PAGE->navbar->add($title, '');
|
||||||
|
echo $OUTPUT->header();
|
||||||
|
echo html_writer::start_tag('pre', ['class' => 'task-output', 'style' => 'min-height: 24lh']);
|
||||||
|
|
||||||
|
echo tool_task_mtrace_wrapper($log->output);
|
||||||
|
echo html_writer::end_tag('pre');
|
||||||
|
echo $OUTPUT->action_link(
|
||||||
|
new moodle_url('/admin/tasklogs.php'),
|
||||||
|
$strheading,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new pix_icon('i/log', ''),
|
||||||
|
);
|
||||||
|
echo ' ';
|
||||||
|
echo $OUTPUT->action_link(
|
||||||
|
new moodle_url('/admin/tasklogs.php', ['logid' => $log->id, 'download' => true]),
|
||||||
|
new lang_string('download'),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new pix_icon('t/download', ''),
|
||||||
|
);
|
||||||
|
|
||||||
|
echo $OUTPUT->footer();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ function tool_task_status_checks(): array {
|
||||||
* @param string $message Message to output
|
* @param string $message Message to output
|
||||||
* @param string $eol End of line character
|
* @param string $eol End of line character
|
||||||
*/
|
*/
|
||||||
function tool_task_mtrace_wrapper(string $message, string $eol): void {
|
function tool_task_mtrace_wrapper(string $message, string $eol = ''): void {
|
||||||
$message = s($message);
|
$message = s($message);
|
||||||
|
|
||||||
// We autolink urls and emails here but can't use format_text as it does
|
// We autolink urls and emails here but can't use format_text as it does
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.path-admin-tool-task .task-output {
|
.path-admin .task-output {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: #333;
|
background: #333;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue