<?php

namespace Simplyin\Simplyin_W_Plugin;

use Simplyin\Simplyin_W_Plugin\Lib\Base_Plugin\Woocommerce_Logger;

class Simplyin_Logger {

	public function log_if_wpdebug_on( string $message, string $context = "" ) {
		$woo_logger = simplyin()
			->get_woocommerce_logger( $context === "" ? null : $context );

		$woo_logger->log_debug( $message );
	}

	public function force_log_to_woocommerce( string $message, string $context = '' ) {
		$woo_logger = simplyin()
			->get_woocommerce_logger( '' === $context ? null : $context );

		if ( $woo_logger instanceof Woocommerce_Logger ) {
			$woo_logger->log_debug( $message );
			return;
		}

		if ( ! class_exists( 'WC_Log_Handler_File' ) ) {
			return;
		}

		$fallback_logger = new Woocommerce_Logger( '' === $context ? 'simplyin' : $context );
		$fallback_logger->log_debug( $message );
	}
}
