Commit b26af4ed authored by tufengqi's avatar tufengqi

修改记录日志的格式

parent fc22d41b
...@@ -29,31 +29,22 @@ class Application extends Component ...@@ -29,31 +29,22 @@ class Application extends Component
echo $this->terry . "Hello Welcome to MyComponent"; echo $this->terry . "Hello Welcome to MyComponent";
} }
private function checkAndFilterLog($arr_code_arr) public function info($cate, $code, $class, $func, $user_data)
{ {
if ((empty($arr_code_arr['code']) && empty($arr_code_arr['arr'])) \Yii::info($code . "\t" . json_encode([
|| (!empty($arr_code_arr['code']) && !is_numeric($arr_code_arr['code'])) 'class' => $class,
|| (!empty($arr_code_arr['arr']) && !is_array($arr_code_arr['arr']))) { 'function' => $func,
exit('check param one,code json'); 'user_data' => $user_data
} ]), $cate_name);
if (empty($arr_code_arr['code'])) {
$arr_code_arr['code'] = 0;
}
if (empty($arr_code_arr['arr'])) {
$arr_code_arr['arr'] = "";
}
return $arr_code_arr;
}
public function info($arr_code_arr, $cate_name)
{
$arr_code_arr = $this->checkAndFilterLog($arr_code_arr);
\Yii::info($arr_code_arr['code'] . "\t" . json_encode($arr_code_arr['arr']), $cate_name);
} }
public function error($arr_code_arr, $cate_name) public function error($cate, $code, $class, $func, $user_data)
{ {
$arr_code_arr = $this->checkAndFilterLog($arr_code_arr); \Yii::error($code . "\t" . json_encode([
\Yii::error($arr_code_arr['code'] . "\t" . json_encode($arr_code_arr['arr']), $cate_name); 'class' => $class,
'function' => $func,
'user_data' => $user_data
]), $cate_name);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment