diff --git a/admin/classes/reportbuilder/local/entities/task_log.php b/admin/classes/reportbuilder/local/entities/task_log.php index 4922822744a..f2937997268 100644 --- a/admin/classes/reportbuilder/local/entities/task_log.php +++ b/admin/classes/reportbuilder/local/entities/task_log.php @@ -105,9 +105,10 @@ class task_log extends base { )) ->add_joins($this->get_joins()) ->set_type(column::TYPE_TEXT) - ->add_field("$tablealias.classname") + ->add_fields("{$tablealias}.classname, {$tablealias}.id") ->set_is_sortable(true) - ->add_callback(static function(string $classname): string { + ->add_callback(static function($value, stdClass $row): string { + $classname = $row->classname; $output = ''; if (class_exists($classname)) { $task = new $classname; @@ -118,6 +119,7 @@ class task_log extends base { $output .= \html_writer::tag('div', "\\{$classname}", [ 'class' => 'small text-muted', ]); + $output = \html_writer::link(new \moodle_url('/admin/tasklogs.php', ['logid' => $row->id]), $output); return $output; }); diff --git a/admin/classes/reportbuilder/local/systemreports/task_logs.php b/admin/classes/reportbuilder/local/systemreports/task_logs.php index be35ae3be6a..b68e5017afd 100644 --- a/admin/classes/reportbuilder/local/systemreports/task_logs.php +++ b/admin/classes/reportbuilder/local/systemreports/task_logs.php @@ -143,7 +143,7 @@ class task_logs extends system_report { new moodle_url('/admin/tasklogs.php', ['logid' => ':id']), new pix_icon('e/search', ''), [], - true, + false, new lang_string('view'), ))); diff --git a/admin/tasklogs.php b/admin/tasklogs.php index 57788d1c17b..526ffa4686f 100644 --- a/admin/tasklogs.php +++ b/admin/tasklogs.php @@ -24,6 +24,7 @@ require_once(__DIR__ . '/../config.php'); require_once("{$CFG->libdir}/adminlib.php"); +require_once("tool/task/lib.php"); use core_admin\reportbuilder\local\systemreports\task_logs; use core_reportbuilder\system_report_factory; @@ -49,9 +50,41 @@ if (null !== $logid) { if ($download) { $filename = str_replace('\\', '_', $log->classname) . "-{$log->id}.log"; 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; } diff --git a/admin/tool/task/lib.php b/admin/tool/task/lib.php index 655855367c3..c1813db730f 100644 --- a/admin/tool/task/lib.php +++ b/admin/tool/task/lib.php @@ -44,7 +44,7 @@ function tool_task_status_checks(): array { * @param string $message Message to output * @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); // We autolink urls and emails here but can't use format_text as it does diff --git a/admin/tool/task/styles.css b/admin/tool/task/styles.css index 6b118e831dd..addd0c058cc 100644 --- a/admin/tool/task/styles.css +++ b/admin/tool/task/styles.css @@ -16,7 +16,7 @@ font-size: 0.75em; } -.path-admin-tool-task .task-output { +.path-admin .task-output { color: #fff; background: #333; padding: 1em;