<?php
/**
 * Authorize.net Logger Class
 *
 * Logs debug messages related to the WooCommerce Authorize.net Gateway.
 *
 * @package Authorize_Net_Payments_For_Woocommerce
 * @subpackage Authorize_Net_Payments_For_Woocommerce/includes
 */

if (! defined('ABSPATH')) {
	exit;
}

/**
 * Class Anet_Logger
 *
 * Provides logging functionality for the Authorize.net WooCommerce gateway.
 */
class Anet_Logger
{
	/**
	 * WC_Logger instance used for logging messages.
	 *
	 * @var WC_Logger
	 */
	public static $logger;
	/**
	 * Logs a message to the WooCommerce Authorize.net log file.
	 *
	 * @param string $message The message to log.
	 * @param string $payment_type The payment type for context (optional).
	 * @param string $level The log level: 'error', 'warning', 'info', or 'debug'.
	 *
	 * @return void
	 */
	public static function log($message, $payment_type = '', $level = 'debug')
	{
		if (! class_exists('WC_Logger')) {
			return;
		}
		if (empty(self::$logger)) {
			self::$logger = wc_get_logger();
		}
		$context = array('source' => 'authorize-net-payments-for-woocommerce');
		switch ($level) {
			case 'error':
				self::$logger->error($message, $context);
				break;
			case 'warning':
				self::$logger->warning($message, $context);
				break;
			case 'info':
				self::$logger->info($message, $context);
				break;
			default:
				self::$logger->debug($message, $context);
				break;
		}
	}
}
