1212 */
1313class Log {
1414
15+ public static const NONE = 'none ' ;
16+ public static const DEBUG = 'debug ' ;
17+ public static const INFO = 'info ' ;
18+ public static const WARN = 'warn ' ;
19+ public static const ERROR = 'error ' ;
20+
1521 /** The available log priorities */
1622 protected static $ logPriorities ;
1723 /** The log level to issue in error_log */
@@ -29,7 +35,7 @@ class Log {
2935 */
3036 public static function instance () {
3137 if (self ::$ logLevel == null ) {
32- self ::$ logLevel == ' info ' ;
38+ self ::$ logLevel == INFO ;
3339 }
3440 if (self ::$ instance == null ) {
3541 self ::$ instance = new Log ();
@@ -103,7 +109,7 @@ public function getStackTrace($excludeFile = NULL) {
103109 * @param mixed $o - an oject to be dumped along with message. An Exception object will cause a stacktrace dump (optional).
104110 */
105111 public static function debug ($ s , $ o = null ) {
106- self ::instance ()->log (' debug ' , $ s , $ o );
112+ self ::instance ()->log (DEBUG , $ s , $ o );
107113 }
108114
109115 /**
@@ -112,7 +118,7 @@ public static function debug($s, $o = null) {
112118 * @param mixed $o - an oject to be dumped along with message. An Exception object will cause a stacktrace dump (optional).
113119 */
114120 public static function info ($ s , $ o = null ) {
115- self ::instance ()->log (' info ' , $ s , $ o );
121+ self ::instance ()->log (INFO , $ s , $ o );
116122 }
117123
118124 /**
@@ -121,7 +127,7 @@ public static function info($s, $o = null) {
121127 * @param mixed $o - an oject to be dumped along with message. An Exception object will cause a stacktrace dump (optional).
122128 */
123129 public static function warn ($ s , $ o = null ) {
124- self ::instance ()->log (' warn ' , $ s , $ o );
130+ self ::instance ()->log (WARN , $ s , $ o );
125131 }
126132
127133 /**
@@ -130,39 +136,39 @@ public static function warn($s, $o = null) {
130136 * @param mixed $o - an oject to be dumped along with message. An Exception object will cause a stacktrace dump (optional).
131137 */
132138 public static function error ($ s , $ o = null ) {
133- self ::instance ()->log (' error ' , $ s , $ o );
139+ self ::instance ()->log (ERROR , $ s , $ o );
134140 }
135141
136142 /**
137143 * Print stacktrace into debug log, optionally excluding a certain file from trace.
138144 * @param string $excludeFile - the file to be excluded (optional).
139145 */
140146 public static function debugStackTrace ($ excludeFile = NULL ) {
141- self ::instance ()->logStackTrace (' debug ' , $ excludeFile );
147+ self ::instance ()->logStackTrace (DEBUG , $ excludeFile );
142148 }
143149
144150 /**
145151 * Print stacktrace into info log, optionally excluding a certain file from trace.
146152 * @param string $excludeFile - the file to be excluded (optional).
147153 */
148154 public static function infoStackTrace ($ excludeFile = NULL ) {
149- self ::instance ()->logStackTrace (' info ' , $ excludeFile );
155+ self ::instance ()->logStackTrace (INFO , $ excludeFile );
150156 }
151157
152158 /**
153159 * Print stacktrace into warning log, optionally excluding a certain file from trace.
154160 * @param string $excludeFile - the file to be excluded (optional).
155161 */
156162 public static function warnStackTrace ($ excludeFile = NULL ) {
157- self ::instance ()->logStackTrace (' warn ' , $ excludeFile );
163+ self ::instance ()->logStackTrace (WARN , $ excludeFile );
158164 }
159165
160166 /**
161167 * Print stacktrace into error log, optionally excluding a certain file from trace.
162168 * @param string $excludeFile - the file to be excluded (optional).
163169 */
164170 public static function errorStackTrace ($ excludeFile = NULL ) {
165- self ::instance ()->logStackTrace (' error ' , $ excludeFile );
171+ self ::instance ()->logStackTrace (ERROR , $ excludeFile );
166172 }
167173
168174 /**
@@ -210,7 +216,7 @@ public static function get() {
210216 */
211217 protected static function isLogLevelIncluded ($ sev ) {
212218 if (self ::$ logPriorities == null ) {
213- self ::$ logPriorities = array (' none ' , ' debug ' , ' info ' , ' warning ' , ' error ' );
219+ self ::$ logPriorities = array (NONE , DEBUG , INFO , WARN , ERROR );
214220 }
215221 $ logIndex = array_search (self ::$ logLevel , self ::$ logPriorities );
216222 $ sevIndex = array_search ($ sev , self ::$ logPriorities );
0 commit comments