bibhamrokhanpin/wp-content/__plugins/wp-optimize/includes/class-updraft-php-logger.php

132 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2024-04-10 12:01:06 +00:00
<?php
if (!defined('ABSPATH')) die('No direct access allowed');
if (class_exists('Updraft_PHP_Logger')) return;
if (!class_exists('Updraft_Abstract_Logger')) require_once('class-updraft-abstract-logger.php');
/**
* Class Updraft_PHP_Logger
*/
class Updraft_PHP_Logger extends Updraft_Abstract_Logger {
/**
* Updraft_PHP_Logger constructor
*/
public function __construct() {
}
/**
* Returns logger description
*
* @return string|void
*/
public function get_description() {
return __('Log events into the PHP error log', 'wp-optimize');
}
/**
* Emergency message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function emergency($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::EMERGENCY, $context);
}
/**
* Alert message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function alert($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::ALERT, $context);
}
/**
* Critical message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function critical($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::CRITICAL, $context);
}
/**
* Error message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function error($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::ERROR, $context);
}
/**
* Warning message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function warning($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::WARNING, $context);
}
/**
* Notice message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function notice($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::NOTICE, $context);
}
/**
* Info message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function info($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::INFO, $context);
}
/**
* Debug message
*
* @param string $message
* @param array $context
* @return null|void
*/
public function debug($message, array $context = array()) {
$this->log($message, Updraft_Log_Levels::DEBUG, $context);
}
/**
* Log message with any level
*
* @param string $message
* @param mixed $level
* @param array $context
* @return null|void
*/
public function log($message, $level, array $context = array()) {
if (!$this->is_enabled()) return false;
$message = '['.Updraft_Log_Levels::to_text($level).'] : '.$this->interpolate($message, $context);
error_log($message);
}
}