messages[] = array( 'time' => $time, 'type' => $type, 'body' => $message, ); } // Zapisemo sporocila v log file public function write(){ // Nimamo sporocil - ne naredimo nicesar if (empty($this->messages)){ return; } // Ime loga $filename = LOG_FOLDER.date('Y-m-d').'.log'; // Ce dnevni log file se ne obstaja ga ustvarimo in nastavimo pravice if (!file_exists($filename)){ // Create the log file file_put_contents($filename, 'Loging by class.SurveyLog.php'.PHP_EOL); // Allow anyone to write to log files //chmod($filename, 0666); } // Set the log line format $format = 'time --- type: body'; // Loop cez vsa sporocila in zapis v file foreach ($this->messages as $message){ file_put_contents($filename, PHP_EOL.strtr($format, $message), FILE_APPEND); } // Resetiramo array s sporocili $this->messages = array(); } }