WooCommerce Code Reference

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
Level strings mapped to integer severity.
$severity_to_level  : array
Severity integers mapped to level strings.
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

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
see

@link {https://tools.ietf.org/html/rfc5424}

Properties

$level_to_severity

Level strings mapped to integer severity.

protected static array $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 $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_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
int100 (debug) - 800 (emergency) or 0 if not recognized

get_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|stringFalse 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.

Return values
boolTrue if $level is a valid level.