<?php

declare(strict_types=1);

namespace Cin\Quickpurchase;

final class Logger
{
  public static function info(string $action, string $meta = ''): void
  {
    self::doLog($action, $meta, 'info');
  }

  public static function warn(string $action, string $meta = ''): void
  {
    self::doLog($action, $meta, 'warn');
  }

  public static function error(string $action, string $meta = ''): void
  {
    self::doLog($action, $meta, 'error');
  }

  private static function doLog(string $action, string $meta, string $status): void
  {
    $P    = new Plugin();
    $stmt = $P->getPDO()->prepare('INSERT INTO `xplugin_cin_quick_purchase_5_log` (action, meta, status) VALUES (:action, :meta, :status)');
    $stmt->execute([
      ':action' => $action,
      ':meta'   => $meta,
      ':status' => $status
    ]);
  }
}
