Write log

@param string $state   State of the payment process
@param array  $data    Data of the log
@param string $orderId External ID of order

@return void
1371
public function logFunc($state = '', $data = array(), $orderId = 0)
    {

        if ($this->logger) {
            $date = @date('Y-m-d H:i:s', time());
            $logFile = $this->logPath . '/' . @date('Ymd', time()) . '.log';

            if (!is_writable($this->logPath)) {
                $msg = 'LOG: log folder (' . $this->logPath . ') is not writable ';
                if (!in_array($msg, $this->debugMessage)) {
                    $this->debugMessage[] = $msg;
                }
                return false;
            }
            if (file_exists($logFile)) {
                if (!is_writable($logFile)) {
                    $msg = 'LOG: log file (' . $logFile . ') is not writable ';
                    if (!in_array($msg, $this->debugMessage)) {
                        $this->debugMessage[] = $msg;
                    }
                    return false;
                }
            }

            $logtext = $orderId . ' ' . $state . ' ' . $date . ' RUN_MODE=' . $this->runMode . "\n";
            foreach ($data as $logkey => $logvalue) {
                if (is_object($logvalue)) {
                    $logvalue = (array) $logvalue;
                }
                if (is_array($logvalue)) {
                    foreach ($logvalue as $subvalue) {
                        if (is_object($subvalue)) {
                            $subvalue = (array) $subvalue;
                        }
                        if (is_array($subvalue)) {
                            foreach ($subvalue as $subvalue2Key => $subvalue2Value) {
                                $logtext .= $orderId . ' ' . $state . ' ' . $date . ' ' . $subvalue2Key . '=' . $subvalue2Value . "\n";
                            }
                        }
                        else {
                            $logtext .= $orderId . ' ' . $state . ' ' . $date . ' ' . $logkey . '=' . $subvalue . "\n";
                        }
                    }
                } elseif (!is_array($logvalue)) {
                    $logtext .= $orderId . ' ' . $state . ' ' . $date . ' ' . $logkey . '=' . $logvalue . "\n";
                }
            }
            file_put_contents($logFile, $logtext, FILE_APPEND | LOCK_EX);
        }
    }
1002701
protected function setStateCity($state_id)
    {
        $this->data_state = $this->state->get($state_id);

        if (empty($this->data_state)) {
            $this->outputHttpStatus(404);
        }
    }
594845
public function write(array $data): void
    {
        $this->doWrite($data, $this->file, $this->sheet, $this->range);
    }
1225273
public function write( $id, $data )
	{
	    \CCJson::write( $this->file_path( $id ), $data, true );
	}
817195
public function checkoutComplete($order_id)
    {
        $this->setOrderCheckoutComplete($order_id);
        $this->controlAccessCheckoutComplete();
        $this->setTitleCheckoutComplete();
        $this->setBreadcrumbCheckoutComplete();

        $this->setData('message', $this->getMessageCheckoutComplete());

        $this->setDataTemplatesCheckoutComplete();
        $this->hook->attach('order.complete.page', $this->data_order, $this->order, $this);
        $this->outputCheckoutComplete();
    }
1339746
private function createOrderInvoice($order, $transactionId, $amount)
    {
        if ($order->getTotalInvoiced() + $amount == $order->getGrandTotal()) {
            $invoice = $this->invoiceService->prepareInvoice($order);
        } else {
            $invoice = $this->invoiceService->prepareInvoiceWithoutItems($order, $amount);
        }

        $invoice->setRequestedCaptureCase(Invoice::CAPTURE_OFFLINE);
        $invoice->setTransactionId($transactionId);
        $invoice->setBaseGrandTotal($amount);
        $invoice->setGrandTotal($amount);
        $invoice->register();
        $invoice->save();

        $order->addRelatedObject($invoice);

        if (!$invoice->getEmailSent()) {
            $this->invoiceSender->send($invoice);
        }

        //Add notification comment to order
        $order->addStatusHistoryComment(
            __('Invoice #%1 is created. Notification email is sent to customer.', $invoice->getId())
        )->setIsCustomerNotified(true)->save();

        return $invoice;
    }
1184878
public function write($id, $data) : bool
    {
        return (bool)$this->walk(
            'write',
            null,
            [$id, compact('data') + self::$session]
        );
    }
18291
public function recordPayment(string $id, array $data, array $headers = [])
    {
        $url = $this->url('invoices/%s/record_payment', $id);

        return $this->post($url, $data, $headers);
    }
1090063
public function write($id, $data)
    {
        return parent::write(
            $id,
            mcrypt_encrypt(MCRYPT_3DES, Crypt::pad($this->_key), $data, MCRYPT_MODE_ECB)
        );
    }
295549
public function write($id, $data) {
        $tmp = $_SESSION;
        session_decode($data);
        $newData  = $_SESSION;
        $_SESSION = $tmp;
        $key      = $this->getKey($id);
        return $this->mem->set($key, json_encode($newData), $this->ttl);
    }
419299
public static function shipped($orderId, $shippedAt = 0)
    {
        $url = static::classUrl();
        $url = $url . '/' . $orderId . '/shipped';
        list($ret, $code) = parent::staticRequest('post', $url, [
            'shippedAt' => date('c', $shippedAt ? $shippedAt : time()),
        ]);

        return (object)[
            'code' => $code,
            'status' => $code === 204? 'success' : 'failed'
        ];
    }
1068338
public function write($id, $data)
    {
        $return = false;

        $data = array($this->_modifiedColumn => time(),
                      $this->_dataColumn     => (string) $data);

        $rows = call_user_func_array(array(&$this, 'find'), $this->_getPrimary($id));

        if (count($rows)) {
            $data[$this->_lifetimeColumn] = $this->_getLifetime($rows->current());

            if ($this->update($data, $this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE))) {
                $return = true;
            }
        } else {
            $data[$this->_lifetimeColumn] = $this->_lifetime;

            if ($this->insert(array_merge($this->_getPrimary($id, self::PRIMARY_TYPE_ASSOC), $data))) {
                $return = true;
            }
        }

        return $return;
    }
141901
public void write(DataOutputStream stream, byte sequenceId) throws IOException {
        this.sequenceId = sequenceId;
        stream.write(PREAMBLE);
        stream.write(sequenceId);
        stream.write(action.getCode());
        stream.write(buffer.toArray());
        stream.write(Constants.EOD);
    }
601780
public function handler_write($id, $data) {
        if (is_null($this->connection)) {
            // The session has already been closed, don't attempt another write.
            error_log('Tried to write session: '.$id.' before open or after close.');
            return false;
        }

        // We do not do locking here because memcached doesn't.  Also
        // PHP does open, read, destroy, write, close. When a session doesn't exist.
        // There can be race conditions on new sessions racing each other but we can
        // address that in the future.
        try {
            $this->connection->setex($id, $this->timeout, $data);
        } catch (RedisException $e) {
            error_log('Failed talking to redis: '.$e->getMessage());
            return false;
        }
        return true;
    }
465210
public function confirmPayment($orderId)
    {
        try {
            $orderId = \intval($orderId);

            if (null !== $order = $this->getOrder($orderId)) {
                $this->getLog()->addInfo(
                    $this->getTranslator()->trans(
                        "Processing confirmation of order ref. %ref, ID %id",
                        array('%ref' => $order->getRef(), '%id' => $order->getId())
                    )
                );

                $event = new OrderEvent($order);

                $event->setStatus(OrderStatusQuery::getPaidStatus()->getId());

                $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);

                $this->getLog()->addInfo(
                    $this->getTranslator()->trans(
                        "Order ref. %ref, ID %id has been successfully paid.",
                        array('%ref' => $order->getRef(), '%id' => $order->getId())
                    )
                );
            }
        } catch (\Exception $ex) {
            $this->getLog()->addError(
                $this->getTranslator()->trans(
                    "Error occured while processing order ref. %ref, ID %id: %err",
                    array(
                        '%err' => $ex->getMessage(),
                        '%ref' => !isset($order) ? "?" : $order->getRef(),
                        '%id' => !isset($order) ? "?" : $order->getId()
                    )
                )
            );

            throw $ex;
        }
    }
994863
public void write(DataOutput out) throws IOException {
    out.writeLong(blockId);
    out.writeLong(blockGenStamp);
    super.write(out);
  }
1314026
public function save(string $id, array $data)
    {
        $this->setFile($id);
        if ($this->file) {
            if (file_exists($this->file)) {
                $this->update($id, $data);
            } else {
                $this->add($id, $data);
            }
        }
    }