I am working on Moodle project.I want to is there a way I can write my error into Log.txt file in PHP.
Below is my code
class drill_auto_enrolluser extends \core\task\scheduled_task{
public function execute() {
global $DB;
$name="";
$description="";
$descriptionformat ="";
$userid="";
$templateid="";
$timecreated="";
$timemodified=0;
$origtemplateid=NULL;
$status=0;
$duedate=0;
$reviewerid=NULL;
$DATA = $DB->get_recordset_sql ("Select name,description,descriptionformat,userid,templateid from vw_new_user_lp");
foreach ($DATA as $id => $rec) {
$record = new \stdClass();
$record ->name = $rec->name;
$record ->description= $rec->description;
$record ->descriptionformat=$rec->descriptionformat;
$record ->userid= $rec->userid;
$record->origtemplateid=$origtemplateid;
$record ->templateid=$rec->templateid;
$record->status= $status;
$record->duedate= $duedate;
$record->reviewerid= $reviewerid;
$record->timecreated= time();
$record->timemodified = $timemodified;
$record->usermodified = $userid;
$DB->insert_record('competency', $record);
}
}
}