MDL-66570 admin: Add setting to hide captured cron log output

This commit is contained in:
Andrew Nicols
2019-09-17 14:03:31 +08:00
parent 1c3efe48f8
commit e044c3debe
5 changed files with 27 additions and 6 deletions
+13 -2
View File
@@ -76,13 +76,18 @@ class logmanager {
*/
protected static $oblevel = null;
/**
* @var bool Output logged content to screen.
*/
protected static $outputloggedcontent = true;
/**
* Create a new task logger for the specified task, and prepare for logging.
*
* @param \core\task\task_base $task The task being run
*/
public static function start_logging(task_base $task) {
global $DB;
global $CFG, $DB;
if (!self::should_log()) {
return;
@@ -129,6 +134,8 @@ class logmanager {
self::$oblevel = null;
}
self::$outputloggedcontent = !empty($CFG->task_logtostdout);
// Start capturing output.
ob_start([\core\task\logmanager::class, 'add_line'], self::CHUNKSIZE);
}
@@ -336,6 +343,10 @@ class logmanager {
fwrite(self::$fh, $log);
}
return $log;
if (self::$outputloggedcontent) {
return $log;
} else {
return '';
}
}
}