YULRedisLogger.class.php
1.32 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
<?php
require_once dirname(__FILE__).'/config/redisLogger.const.inc.php';
require_once dirname(__FILE__).'/loggerMQ/YMQLoggerRecorder.class.php';
class YULRedisLogger {
private static $LOG_SEPARATOR = '|';
public static function log($userID, $funcID, $param, $result, $ip, $client)
{
$data = self::_buildLogData($userID, $funcID, $param, $result, $ip, $client);
self::_log($data, REDIS_LOGGER_TYPE_OPT);
}
private static function _log($data, $type = REDIS_LOGGER_TYPE_OPT)
{
YMQLoggerRecorder::set($type, $data);
}
public static function persist()
{
YMQLoggerRecorder::save();
}
/**
* 用户ID|方法ID|调用的参数|返回值|时间|IP地址|浏览器类型
*
* Enter description here ...
* @param unknown_type $userID
* @param unknown_type $funcID
* @param unknown_type $param
* @param unknown_type $result
* @param unknown_type $ip
* @param unknown_type $client
*/
private static function _buildLogData($userID, $funcID, $param, $response, $ip, $client)
{
$result = $userID;
$result .= self::$LOG_SEPARATOR.$funcID;
$result .= self::$LOG_SEPARATOR.json_encode($param);
$result .= self::$LOG_SEPARATOR.json_encode($response);
$result .= self::$LOG_SEPARATOR.time();
$result .= self::$LOG_SEPARATOR.$ip;
$result .= self::$LOG_SEPARATOR.$client;
return $result;
}
}
?>