Skip to content

Instantly share code, notes, and snippets.

@mudrd8mz
Created January 21, 2019 15:04
Show Gist options
  • Save mudrd8mz/930b8a993789f2a3da77955c3aab48e5 to your computer and use it in GitHub Desktop.
Save mudrd8mz/930b8a993789f2a3da77955c3aab48e5 to your computer and use it in GitHub Desktop.
Moodle mtrace modification that makes PID appear in cron logs
commit xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Author: David Mudrák <david@moodle.com>
Date: Mon Jan 21 15:49:09 2019 +0100
Include PID in mtrace console output, e.g. in cron logs
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 18e7a74cef..8d45d8d84c 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -8949,7 +8949,7 @@ function mtrace($string, $eol="\n", $sleep=0) {
$fn($string, $eol);
return;
} else if (defined('STDOUT') && !PHPUNIT_TEST && !defined('BEHAT_TEST')) {
- fwrite(STDOUT, $string.$eol);
+ fwrite(STDOUT, '[PID '.(string) getmypid().'] '.$string.$eol);
} else {
echo $string . $eol;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment