<?php
if (!defined('ABSPATH')) exit;

class gam_ads_ad_manager_and_ad_exchange_Logs {

    public static function log($logContent)
    {
        $upload_dir = wp_upload_dir();
        $log_dir = $upload_dir['basedir'] . '/gam-ads-ad-manager-and-ad-exchange-logs/';
        if (!file_exists($log_dir)) {
            // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir
            mkdir($log_dir, 0755, true);
        }

        $log_file = $log_dir . 'main.log';
        $date = gmdate('Y-m-d H:i:s');
        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
        file_put_contents($log_file, "[$date] $logContent" . PHP_EOL, FILE_APPEND);
    }

    public static function GAMlog($logContent)
    {
        $upload_dir = wp_upload_dir();
        $log_dir = $upload_dir['basedir'] . '/gam-ads-ad-manager-and-ad-exchange-logs/';
        if (!file_exists($log_dir)) {
            // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir
            mkdir($log_dir, 0755, true);
        }

        $log_file = $log_dir . 'GAMlog.log';
        $date = gmdate('Y-m-d H:i:s');
        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
        file_put_contents($log_file, "[$date] $logContent" . PHP_EOL, FILE_APPEND);
    }
}