/** * @param LogEntry $entry * * @throws \Exception */ protected function persist(LogEntry $entry) { if (!($file = fopen($this->logFilePath, 'a'))) { throw new FileNotWritableException($this->logFilePath); } $lineToWrite = sprintf("%s;%s;%s\n", (new \DateTime())->format("Y-m-d H:i:s"), $entry->getEmailAddress(), $entry->getFailureReason()); if (false === fwrite($file, $lineToWrite)) { throw new FileNotWritableException($this->logFilePath); } fclose($file); }
/** * @param LogEntry $entry */ protected function persist(LogEntry $entry) { $this->wpdb->insert(sprintf("%s%s", $this->wpdb->prefix, $this->logTableName), array('email_address' => $entry->getEmailAddress(), 'reason' => $entry->getFailureReason(), 'submission_date' => (new \DateTime())->format('Y-m-d H:i:s')), array('%s', '%s', '%s')); }