HEX
Server: LiteSpeed
System: Linux server902.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: deshuvsd (2181)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/thread-self/root/home/deshuvsd/www/wp-content/plugins/surerank/inc/traits/logger.php
<?php
/**
 * Logger.
 *
 * @package surerank;
 * @since 1.2.0
 */

namespace SureRank\Inc\Traits;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Logger
 *
 * @since 1.0.0`
 */
trait Logger {

	/**
	 * Log an error message to the WordPress debug log.
	 *
	 * @param string $message The error message to log.
	 * @param string $type    The type of log message. Can be 'log', 'error', or 'warning'.
	 *
	 * @return void
	 */
	public static function log( string $message, string $type = 'log' ) {
		if ( defined( 'SURERANK_DEBUG' ) && SURERANK_DEBUG ) {
			error_log( $message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
		}

		if ( defined( 'WP_CLI' ) && WP_CLI ) {
			if ( 'log' === $type || 'info' === $type ) {
				\WP_CLI::log( $message );
			} elseif ( 'error' === $type ) {
				\WP_CLI::error( $message );
			} else {
				\WP_CLI::warning( $message );
			}
		}
	}

}