<?php
class ModelErrorLog extends Model {
    public function writeLogs($type, $method, $message) {
        //Sample Log - 2023-05-04 17:26:10 Trace. Method:DeleteUser; Message:User Id 7 been deleted by User Id 1.
        $logText = date('Y-m-d H:i:s') . " " . $type . ". Method:" . $method . "; Message:" . $message . ".\n";
        $this->logger($logText);
    }

    public function logger($message) {
        $fileName = "/logs_" . date('Ymd') . ".txt";
        $fp = fopen(DIR_APPLICATION . "/logs" . $fileName, "w");
        fwrite($fp, $message);
        fclose($fp);
    }
}