Warning: Constant SEO_LINKS_API_ENDPOINT already defined in /www/wwwroot/fni.gov.mz/wp-content/plugins/wordpress-plugin/wordpress-plugin.php on line 10
HEX
HEX
Server: Apache
System: Linux paginas.localdomain 4.15.0-200-generic #211-Ubuntu SMP Thu Nov 24 18:16:04 UTC 2022 x86_64
User: www (1002)
PHP: 8.0.11
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/fni.gov.mz/wp-content/themes/Newspaper/includes/wp_booster/td_log.php
<?php
/**
 * Log class, used by the theme. Is loaded only when needed.
 * The key used to store the log is: TD_THEME_OPTIONS_NAME . '_log'  (ex: td_011_log)
 */
class td_log {
	private static $log_cache = array();
	private static $is_shutdown_hooked = false;

	private static $log_info = true;

	/**
	 * Logs a message to the theme's log system. The message is always logged
	 * @param $file string - Usually is __FILE__ - the file that generated the log.
	 * @param $function string- Usually is __FUNCTION__ - the function that generated the log
	 * @param $msg string - the log message
	 * @param $more_data string|object|array  - more data, it can be string, object or array
	 */
	static function log($file, $function, $msg, $more_data = '') {

	    // check td log status
        $td_log_status = td_options::get('td_log_status');

        // as off version 9.x we don't store logs unless they are turned on from system status > TD Log section
        if ( $td_log_status === 'off' ) {
            return;
        }

		// read the cache from db if needed
		if (empty(self::$log_cache)) {
			self::$log_cache = get_option(TD_THEME_OPTIONS_NAME . '_log');
		}

		// limit the log size
        if ( is_array(self::$log_cache) or is_object(self::$log_cache) ) {
            if (count(self::$log_cache) > 20) {
                array_shift(self::$log_cache); //remove first element
            }
        }

		self::$log_cache []= array(
			'file' => $file,
			'function' => $function,
			'msg' => $msg,
			'more_data' => $more_data,
			'timestamp' => time()  //date('j/n/Y G:i:s')
		);

		// make sure that we hook only once
		if (self::$is_shutdown_hooked === false) {
			add_action('shutdown', array(__CLASS__, 'on_shutdown_save_log'), 11); // we sometimes have to log from the shutdown hook with 10 priority
			self::$is_shutdown_hooked = true;
		}

	}


	/**
	 * Logs a message ONLY if @see td_log::$log_info is TRUE. Used to log mossage that are not always requiered, only on debug.
	 * @param $file
	 * @param $function
	 * @param $msg
	 * @param string $more_data
	 */
	static function log_info($file, $function, $msg, $more_data = '') {
		if (self::$log_info === true) {
			self::log($file, $function, $msg, $more_data);
		}
	}


	// save the log if needed
	static function on_shutdown_save_log() {
		update_option(TD_THEME_OPTIONS_NAME . '_log', self::$log_cache);
	}

}