LogLevel.php
2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Copyright (C) Alibaba Cloud Computing
* All rights reserved
*/
class Aliyun_Log_Models_LogLevel_LogLevel{
const debug = 'debug';
const info = 'info';
const warn = 'warn';
const error = 'error';
private static $constCacheArray = NULL;
private $level;
/**
* Constructor
*
* @param string $level
*/
private function __construct($level) {
$this->level = $level;
}
/**
* Compares two logger levels.
*
* @param LoggerLevels $other
* @return boolean
*/
public function equals($other) {
if($other instanceof Aliyun_Log_Models_LogLevel_LogLevel) {
if($this->level == $other->level) {
return true;
}
} else {
return false;
}
}
public static function getLevelDebug(){
if(!isset(self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::debug])){
self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::debug] = new Aliyun_Log_Models_LogLevel_LogLevel('debug');
}
return self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::debug];
}
public static function getLevelInfo(){
if(!isset(self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::info])){
self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::info] = new Aliyun_Log_Models_LogLevel_LogLevel('info');
}
return self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::info];
}
public static function getLevelWarn(){
if(!isset(self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::warn])){
self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::warn] = new Aliyun_Log_Models_LogLevel_LogLevel('warn');
}
return self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::warn];
}
public static function getLevelError(){
if(!isset(self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::error])){
self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::error] = new Aliyun_Log_Models_LogLevel_LogLevel('error');
}
return self::$constCacheArray[Aliyun_Log_Models_LogLevel_LogLevel::error];
}
public static function getLevelStr(Aliyun_Log_Models_LogLevel_LogLevel $logLevel){
$logLevelStr = '';
if(null === $logLevel){
$logLevelStr = 'info';
}
switch ($logLevel->level){
case "error":
$logLevelStr= 'error';
break;
case "warn":
$logLevelStr= 'warn';
break;
case "info":
$logLevelStr= 'info';
break;
case "debug":
$logLevelStr= 'debug';
break;
}
return $logLevelStr;
}
}