WC_Log_Levels
in package
Log levels class.
Table of Contents
- ALERT = 'alert'
- CRITICAL = 'critical'
- DEBUG = 'debug'
- EMERGENCY = 'emergency'
- Log Levels
- ERROR = 'error'
- INFO = 'info'
- NOTICE = 'notice'
- WARNING = 'warning'
- $level_to_severity : array<string|int, mixed>
- Level strings mapped to integer severity.
- $severity_to_level : array<string|int, mixed>
- Severity integers mapped to level strings.
- get_all_level_labels() : array<string|int, string>
- Get the UI labels for all log levels.
- get_all_level_severities() : array<string|int, int>
- Get an associative array with `level name => numerical severity` key/value pairs.
- get_all_severity_levels() : array<string|int, string>
- Get an associative array with `numerical severity => level name` key/value pairs.
- get_level_label() : string
- Get the UI label for a log level.
- get_level_severity() : int
- Translate level string to integer.
- get_severity_level() : bool|string
- Translate severity integer to level string.
- is_valid_level() : bool
- Validate a level string.
Constants
ALERT
public
mixed
ALERT
= 'alert'
CRITICAL
public
mixed
CRITICAL
= 'critical'
DEBUG
public
mixed
DEBUG
= 'debug'
EMERGENCY
Log Levels
public
mixed
EMERGENCY
= 'emergency'
Description of levels: 'emergency': System is unusable. 'alert': Action must be taken immediately. 'critical': Critical conditions. 'error': Error conditions. 'warning': Warning conditions. 'notice': Normal but significant condition. 'info': Informational messages. 'debug': Debug-level messages.
Tags
ERROR
public
mixed
ERROR
= 'error'
INFO
public
mixed
INFO
= 'info'
NOTICE
public
mixed
NOTICE
= 'notice'
WARNING
public
mixed
WARNING
= 'warning'
Properties
$level_to_severity
Level strings mapped to integer severity.
protected
static array<string|int, mixed>
$level_to_severity
= array(self::EMERGENCY => 800, self::ALERT => 700, self::CRITICAL => 600, self::ERROR => 500, self::WARNING => 400, self::NOTICE => 300, self::INFO => 200, self::DEBUG => 100)
$severity_to_level
Severity integers mapped to level strings.
protected
static array<string|int, mixed>
$severity_to_level
= array(800 => self::EMERGENCY, 700 => self::ALERT, 600 => self::CRITICAL, 500 => self::ERROR, 400 => self::WARNING, 300 => self::NOTICE, 200 => self::INFO, 100 => self::DEBUG)
This is the inverse of $level_severity.
Methods
get_all_level_labels()
Get the UI labels for all log levels.
public
static get_all_level_labels() : array<string|int, string>
Return values
array<string|int, string> —get_all_level_severities()
Get an associative array with `level name => numerical severity` key/value pairs.
public
static get_all_level_severities() : array<string|int, int>
Return values
array<string|int, int> —get_all_severity_levels()
Get an associative array with `numerical severity => level name` key/value pairs.
public
static get_all_severity_levels() : array<string|int, string>
Return values
array<string|int, string> —get_level_label()
Get the UI label for a log level.
public
static get_level_label(string $level) : string
Parameters
- $level : string
-
Log level, options: emergency|alert|critical|error|warning|notice|info|debug.
Return values
string —get_level_severity()
Translate level string to integer.
public
static get_level_severity(string $level) : int
Parameters
- $level : string
-
Log level, options: emergency|alert|critical|error|warning|notice|info|debug.
Return values
int — 100 (debug) - 800 (emergency) or 0 if not recognizedget_severity_level()
Translate severity integer to level string.
public
static get_severity_level(int $severity) : bool|string
Parameters
- $severity : int
-
Severity level.
Return values
bool|string — False if not recognized. Otherwise string representation of level.is_valid_level()
Validate a level string.
public
static is_valid_level(string $level) : bool
Parameters
- $level : string
-
Log level.