Skip to content

Commit

Permalink
MDL-60671 core_search: Cron output should use mtrace
Browse files Browse the repository at this point in the history
The mtrace function is preferable for plain text logging/progress
output because it can be redirected if necessary. By convention it
is normally used in cron and can be used in CLI tasks if required.

This change makes the text_progress_trace class use mtrace instead
of echo and then flush. (Default behaviour of mtrace is to do
exactly that, but it can be redirected too.)

Before this change, if anybody is relying on mtrace behaviour to
redirect logs of cron output, this will fail for some parts of the
search cron output (and some other places like auth plugins).
  • Loading branch information
sammarshallou authored and Damyon Wiese committed Nov 7, 2017
1 parent 3c171ca commit 66fe9b5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3242,8 +3242,7 @@ class text_progress_trace extends progress_trace {
* @return void Output is echo'd
*/
public function output($message, $depth = 0) {
echo str_repeat(' ', $depth), $message, "\n";
flush();
mtrace(str_repeat(' ', $depth) . $message);
}
}

Expand Down

0 comments on commit 66fe9b5

Please sign in to comment.