logPath = rtrim($logDir, DIRECTORY_SEPARATOR); if (!is_dir($this->logPath)) { mkdir($this->logPath, APP_LOG_PERMISSION, true); } } public function log(string $message, string $level = 'INFO'): void { $filename = date('Y-m-d') . '.log'; $filepath = "{$this->logPath}/{$filename}"; $time = date('Y-m-d H:i:s'); $formatted = "[{$time}] [{$level}] {$message}\n"; file_put_contents($filepath, $formatted, FILE_APPEND); } public function info(string $message): void { $this->log($message, 'INFO'); } public function error(string $message): void { $this->log($message, 'ERROR'); } public function warning(string $message): void { $this->log($message, 'WARNING'); } public function debug(string $message): void { if (defined('APP_DEBUG') && APP_DEBUG) { $this->log($message, 'DEBUG'); } } }