Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : class-strong-log.php
<?php
/**
 * Debug Logger
 */

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

if ( ! class_exists( 'Strong_Log' ) ) :

	class Strong_Log {

		public $name;

		public $filename;

		public $action;

		public function __construct( $name ) {
			$this->set_name( $name );
			$this->set_filename();
			$this->set_log_action();
			$this->add_actions();
		}

		private function set_name( $name = 'main' ) {
			$this->name = $name;
		}

		private function set_filename() {
			$this->filename = apply_filters(
				"strong_log_{$this->name}_filename",
				str_replace( '_', '-', "strong-{$this->name}-debug.log" )
			);
		}

		private function set_log_action() {
			$this->action = "strong_log_{$this->name}";
		}

		public function add_actions() {
			add_action( 'init', array( $this, 'init' ), 20 );
			add_action( 'shutdown', array( $this, 'on_shutdown' ), 20 );
		}

		public function init() {
			// TODO Make admin check optional.
			if ( $this->is_enabled() && current_user_can( 'administrator' ) ) {
				add_action( $this->action, array( $this, 'debug_log' ), 10, 3 );
			}
		}

		private function is_enabled() {
			$options    = get_option( "wpmtst_{$this->name}_debug" );
			$is_enabled = ( isset( $options['log'] ) && $options['log'] );

			return apply_filters( $this->action, $is_enabled );
		}

		public function get_log_file_path() {
			return $this->get_log_file_base( 'basedir' ) . $this->filename;
		}

		public function get_log_file_url() {
			return $this->get_log_file_base( 'baseurl' ) . $this->filename;
		}

		public function get_log_file_base( $base = 'basedir' ) {
			$upload_dir = wp_upload_dir();

			if ( isset( $upload_dir[ $base ] ) ) {
				$log_file_base = $upload_dir[ $base ];
			} else {
				$log_file_base = $upload_dir['basedir'];
			}

			return trailingslashit( $log_file_base );
		}

		/**
		 * Debug log entries.
		 *
		 * @param $entry
		 * @param string $label
		 * @param string $function_name
		 */
		public function debug_log( $entry, $label = '', $function_name = '' ) {
			$this->log( $entry, $label, $function_name );
		}

		/**
		 * Disable debug logging on shutdown.
		 */
		public function on_shutdown() {
			if ( get_transient( $this->action ) ) {
				do_action( $this->action, str_repeat( '-', 50 ), '', current_filter() );
				delete_transient( $this->action );
			}
		}

		/**
		 * Generic logging function.
		 *
		 * @param array|string $data
		 * @param string $label
		 * @param string $function_name
		 */
		public function log( $data, $label = '', $function_name = '' ) {

			$entry = '[' . gmdate( 'Y-m-d H:i:s' ) . ']';

			if ( wp_doing_ajax() ) {
				$entry .= ' | DOING_AJAX';
			}

			if ( $function_name ) {
				$entry .= ' | FN: ' . $function_name;
			}

			$entry .= ' | ';

			if ( $label ) {
				$entry .= $label . ' = ';
			}

			if ( is_array( $data ) || is_object( $data ) ) {
				$entry .= print_r( $data, true );
			} elseif ( is_bool( $data ) ) {
				$entry .= ( $entry ? 'true' : 'false' ) . PHP_EOL;
			} else {
				$entry .= $data . PHP_EOL;
			}

			//$entry .= PHP_EOL;

			error_log( $entry, 3, $this->get_log_file_path() );

			set_transient( $this->action, true );
		}
	}

endif;
© 2026 GrazzMean-Shell