LMSouq
moodle-core Open

How can I write a custom function that will write error to my log file in Php?

BA
Baiju Sharma
1 month ago
3 views
Problem Description
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); } } }

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base