Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Interface for task logging.
  19   *
  20   * @package    core
  21   * @category   task
  22   * @copyright  2018 Andrew Nicols <andrew@nicols.co.uk>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  namespace core\task;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Interface for task logging.
  31   *
  32   * @copyright  2018 Andrew Nicols <andrew@nicols.co.uk>
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  interface task_logger {
  36      /**
  37       * Whether the task is configured and ready to log.
  38       *
  39       * @return  bool
  40       */
  41      public static function is_configured() : bool;
  42  
  43      /**
  44       * Store the log for the specified task.
  45       *
  46       * @param   task_base   $task The task that the log belongs to.
  47       * @param   string      $logpath The path to the log on disk
  48       * @param   bool        $failed Whether the task failed
  49       * @param   int         $dbreads The number of DB reads
  50       * @param   int         $dbwrites The number of DB writes
  51       * @param   float       $timestart The start time of the task
  52       * @param   float       $timeend The end time of the task
  53       */
  54      public static function store_log_for_task(task_base $task, string $logpath, bool $failed,
  55              int $dbreads, int $dbwrites, float $timestart, float $timeend);
  56  
  57      /**
  58       * Whether this task logger has a report available.
  59       *
  60       * @return  bool
  61       */
  62      public static function has_log_report() : bool;
  63  
  64      /**
  65       * Get any URL available for viewing relevant task log reports.
  66       *
  67       * @param   string      $classname The task class to fetch for
  68       * @return  \moodle_url
  69       */
  70      public static function get_url_for_task_class(string $classname) : \moodle_url;
  71  }