| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/wp-statistics/src/Service/Logger/ |
Upload File : |
<?php
namespace WP_Statistics\Service\Logger;
/**
* Abstract base class for logger service.
*/
abstract class AbstractLoggerProvider implements LoggerServiceProviderInterface
{
/**
* Logger identifier.
*
* @var string
*/
protected $name = '';
/**
* Collection of logged errors.
*
* @var array
*/
protected $errors = [];
/**
* Map of PHP error constants to severity levels.
*/
protected static $ERROR_SEVERITY_MAP = [
// Critical errors
E_ERROR => 'critical',
E_PARSE => 'critical',
E_CORE_ERROR => 'critical',
E_COMPILE_ERROR => 'critical',
E_USER_ERROR => 'critical',
E_RECOVERABLE_ERROR => 'critical',
// Standard errors
E_WARNING => 'error',
E_CORE_WARNING => 'error',
E_COMPILE_WARNING => 'error',
E_USER_WARNING => 'error',
// Notices
E_NOTICE => 'notice',
E_USER_NOTICE => 'notice',
E_STRICT => 'notice',
// Deprecation notices
E_DEPRECATED => 'deprecated',
E_USER_DEPRECATED => 'deprecated'
];
/**
* Sets logger identifier.
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Gets current logger name.
*/
public function getName()
{
return $this->name;
}
/**
* Adds single error to collection.
*/
public function setError($error)
{
$errorName = $this->getErrorSeverity(isset($error['type']) ? $error['type'] : E_ERROR);
$this->errors[] = [
'date' => date('Y-m-d H:i:s'),
'name' => $errorName,
'message' => isset($error['message']) ? $error['message'] : '',
'file' => isset($error['file']) ? $error['file'] : '',
'line' => isset($error['line']) ? $error['line'] : 0,
];
return $this;
}
/**
* Sets multiple errors at once.
*/
public function setErrors($errors)
{
$this->errors = $errors;
return $this;
}
/**
* Gets all stored errors.
*/
public function getErrors()
{
return $this->errors;
}
/**
* Maps PHP error number to severity level name.
*
* @param int|string $errno
*/
public function getErrorSeverity($errno)
{
return isset(self::$ERROR_SEVERITY_MAP[$errno]) ? self::$ERROR_SEVERITY_MAP[$errno] : 'unknown';
}
}