<?php

namespace Utils;

class Logger
{
    public static function logError($type, $message, $file, $line)
    {
        date_default_timezone_set('America/Lima');
        $logDir = __DIR__ . '/log/';
        $logFilePath = $logDir . date('Y-m-d') . '_error.log';
        $timestamp = date('Y-m-d H:i:s');
        $logMessage = "[$timestamp] :: $type :: $message :: $file :: $line" . PHP_EOL;
        
        if (!file_exists($logFilePath)) {
            file_put_contents($logFilePath, '');
        }

        file_put_contents($logFilePath, $logMessage, FILE_APPEND);
    }
}
