forked from laruence/mpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.php
55 lines (41 loc) · 1.26 KB
/
Log.php
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
<?php
/*
----------------------------------------------------
Mpass - Multi-Process Socket Server for PHP
copyright (c) 2010 Laruence
http://www.laruence.com
If you have any questions or comments, please email:
laruence@yahoo.com.cn
*/
/**
* A loger for Mpass simple use
* @package Mpass
*/
class Mpass_Log {
private static $last_error = NULL;
public static function record($str, $priority, $scope = "") {
$pid = getmypid();
if (!empty($scope)) {
print "[" . date("Y-m-d H:i:s") . "]-[PID:" . $pid . "]-[". $priority ."][" . $scope . "]" . $str . "\n";
} else {
print "[" . date("Y-m-d H:i:s") . "]-[PID:" . $pid . "]-[". $priority ."]" . $str . "\n";
}
}
public static function log($str, $scope = "") {
if (!MPASS_DEBUG) {
return TRUE;
}
self::record($str, "DEBUG", $scope);
}
public static function warn($str, $scope = "") {
self::record($str, "WARN", $scope);
}
public static function err($str, $scope = "") {
self::$last_error = $str;
self::record($str, "ERROR", $scope);
}
public static function getLastError() {
return self::$last_error;
}
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */