MDL-51109 task: more debug info for failed scheduled tasks
authorDan Poltawski <dan@moodle.com>
Fri, 21 Aug 2015 13:48:36 +0000 (14:48 +0100)
committerDan Poltawski <dan@moodle.com>
Tue, 1 Sep 2015 09:59:55 +0000 (10:59 +0100)
admin/tool/task/cli/schedule_task.php
lib/cronlib.php

index 6904d48..659ee2e 100644 (file)
@@ -149,6 +149,14 @@ if ($execute = $options['execute']) {
         mtrace("... used " . ($DB->perf_get_queries() - $predbqueries) . " dbqueries");
         mtrace("... used " . (microtime(true) - $pretime) . " seconds");
         mtrace("Task failed: " . $e->getMessage());
+        if ($CFG->debugdeveloper) {
+            if (!empty($e->debuginfo)) {
+                mtrace("Debug info:");
+                mtrace($e->debuginfo);
+            }
+            mtrace("Backtrace:");
+            mtrace(format_backtrace($e->getTrace(), true));
+        }
         \core\task\manager::scheduled_task_failed($task);
         get_mailer('close');
         exit(1);
index 5db8ba8..e6e6b46 100644 (file)
@@ -91,6 +91,14 @@ function cron_run() {
                 mtrace("... used " . (microtime(1) - $pretime) . " seconds");
             }
             mtrace("Scheduled task failed: " . $task->get_name() . "," . $e->getMessage());
+            if ($CFG->debugdeveloper) {
+                 if (!empty($e->debuginfo)) {
+                    mtrace("Debug info:");
+                    mtrace($e->debuginfo);
+                }
+                mtrace("Backtrace:");
+                mtrace(format_backtrace($e->getTrace(), true));
+            }
             \core\task\manager::scheduled_task_failed($task);
         }
         get_mailer('close');
@@ -127,6 +135,14 @@ function cron_run() {
                 mtrace("... used " . (microtime(1) - $pretime) . " seconds");
             }
             mtrace("Adhoc task failed: " . get_class($task) . "," . $e->getMessage());
+            if ($CFG->debugdeveloper) {
+                 if (!empty($e->debuginfo)) {
+                    mtrace("Debug info:");
+                    mtrace($e->debuginfo);
+                }
+                mtrace("Backtrace:");
+                mtrace(format_backtrace($e->getTrace(), true));
+            }
             \core\task\manager::adhoc_task_failed($task);
         }
         get_mailer('close');