PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.1
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / logger / class-cartflows-log-levels.php

class-cartflows-log-levels.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.1, at classes/logger/class-cartflows-log-levels.php

109 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Standard log levels
4 *
5 * @version 3.2.0
6 * @package WooCommerce/Classes
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * Log levels class.
13 */
14 abstract class Cartflows_Log_Levels {
15
16 /**
17 * Log Levels
18 *
19 * Description of levels:
20 * 'emergency': System is unusable.
21 * 'alert': Action must be taken immediately.
22 * 'critical': Critical conditions.
23 * 'error': Error conditions.
24 * 'warning': Warning conditions.
25 * 'notice': Normal but significant condition.
26 * 'info': Informational messages.
27 * 'debug': Debug-level messages.
28 *
29 * @see @link {https://tools.ietf.org/html/rfc5424}
30 */
31 const EMERGENCY = 'emergency';
32 const ALERT = 'alert';
33 const CRITICAL = 'critical';
34 const ERROR = 'error';
35 const WARNING = 'warning';
36 const NOTICE = 'notice';
37 const INFO = 'info';
38 const DEBUG = 'debug';
39
40 /**
41 * Level strings mapped to integer severity.
42 *
43 * @var array
44 */
45 protected static $level_to_severity = array(
46 self::EMERGENCY => 800,
47 self::ALERT => 700,
48 self::CRITICAL => 600,
49 self::ERROR => 500,
50 self::WARNING => 400,
51 self::NOTICE => 300,
52 self::INFO => 200,
53 self::DEBUG => 100,
54 );
55
56 /**
57 * Severity integers mapped to level strings.
58 *
59 * This is the inverse of $level_severity.
60 *
61 * @var array
62 */
63 protected static $severity_to_level = array(
64 800 => self::EMERGENCY,
65 700 => self::ALERT,
66 600 => self::CRITICAL,
67 500 => self::ERROR,
68 400 => self::WARNING,
69 300 => self::NOTICE,
70 200 => self::INFO,
71 100 => self::DEBUG,
72 );
73
74
75 /**
76 * Validate a level string.
77 *
78 * @param string $level Log level.
79 * @return bool True if $level is a valid level.
80 */
81 public static function is_valid_level( $level ) {
82 return array_key_exists( strtolower( $level ), self::$level_to_severity );
83 }
84
85 /**
86 * Translate level string to integer.
87 *
88 * @param string $level Log level, options: emergency|alert|critical|error|warning|notice|info|debug.
89 * @return int 100 (debug) - 800 (emergency) or 0 if not recognized
90 */
91 public static function get_level_severity( $level ) {
92 return self::is_valid_level( $level ) ? self::$level_to_severity[ strtolower( $level ) ] : 0;
93 }
94
95 /**
96 * Translate severity integer to level string.
97 *
98 * @param int $severity Serevity level.
99 * @return bool|string False if not recognized. Otherwise string representation of level.
100 */
101 public static function get_severity_level( $severity ) {
102 if ( ! array_key_exists( $severity, self::$severity_to_level ) ) {
103 return false;
104 }
105 return self::$severity_to_level[ $severity ];
106 }
107
108 }
109