public function saveToFile($fileName, $includeHeaders = true) { $target = uFs::fopen($fileName, 'w+', true); if ($this->headers !== null && $includeHeaders) { fputcsv($target, $this->headers); } $currentPosition = ftell($this->fp); rewind($this->fp); stream_copy_to_stream($this->fp, $target); fseek($this->fp, $currentPosition); fclose($target); }
/** * Adhoc logger that simply writes the message to a file. * * @param string $msg The string to be logged * @param string $file The file name for the log file */ public static function log($msg, $file = 'debug.log') { $f = uFs::fopen($file, 'a'); fwrite($f, $msg . PHP_EOL); fclose($f); }