Commit 8bfee942 authored by liuyuzhen's avatar liuyuzhen

日志写入

parent 2e4fd0e5
......@@ -68,4 +68,15 @@ class CommonController extends \Our\Controller_AbstractIndex{
$articleList = $commonProbleService->getProblemList(true);
$this->success($articleList);
}
public function logAction(){
$logContent = trim($this->req[\Our\NameConst::data]['content']);
if(!$logContent){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyLog);
}
$log = \Our\Log::getInstance();
// $log->write(print_r($data, true));
$log->write($logContent,\Our\NameConst::frontLogPath);
$this->success(new stdClass(),\Our\DescribeConst::logWriteSuccess,\Our\DescribeConst::logWriteSuccess);
}
}
\ No newline at end of file
......@@ -58,7 +58,8 @@ class ArrayConst
const defaultAddress = array(
NameConst::cityCode => '0591',
NameConst::lat => '26.053183',
NameConst::lng => '119.24174'
NameConst::lng => '119.24174',
NameConst::address => '横一号路特力林科技大厦'
);
//小程序账号
......
......@@ -86,6 +86,8 @@ class DescribeConst
const paySuccessTips = '支付成功';
const paySuccessSubTips = '感谢您的购买';
const logWriteSuccess = '日志写入成功';
//支付方式描述
const offPay = '线下支付';
const wxPay = '微信支付';
......
......@@ -14,8 +14,8 @@ class Log {
*
* @param string $message
*/
public function write($message) {
fwrite($this->getHandle(), date("Y-m-d H:i:s")
public function write($message,$filePath ='/data/log/application') {
fwrite($this->getHandle($filePath), date("Y-m-d H:i:s")
. "\t" . $message
. "\turi:" . $_SERVER['REQUEST_URI']
. "\tref:" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')
......@@ -27,9 +27,9 @@ class Log {
*
* @return
*/
public function getHandle() {
public function getHandle($filePath ='/data/log/application') {
if (!$this->_handle) {
$this->_handle = fopen(APPLICATION_PATH . '/data/log/application'.date('Ymd').'.log', 'a');
$this->_handle = fopen(APPLICATION_PATH . $filePath .date('Ymd').'.log', 'a');
}
return $this->_handle;
......
......@@ -70,6 +70,7 @@ class NameConst {
const cityCode = 'cityCode';
const lat = 'lat';
const lng = 'lng';
const address = 'address';
const wechatAuthUrl = 'https://api.weixin.qq.com/sns/jscode2session?';
......@@ -156,6 +157,8 @@ class NameConst {
const cancelUnPayedOrderTimePrefix = 'cancelUnPayedOrderTime';
const cancelUnReceivedOrderTimePrefix = 'cancelUnReceivedOrderTime';
const frontLogPath = '/data/log/front';
}
?>
\ No newline at end of file
......@@ -90,6 +90,7 @@ class CodeConfigModel {
const updateMobileMembmerMappingFailed = 10077;
const currentMobileHasBeenBind = 10078;
const otherDriverLogin=10105;
const emptyLog = 10106;
//访问错误
const illegalAccess=200001;
......@@ -745,7 +746,8 @@ class CodeConfigModel {
self::updateMobileMembmerMappingFailed => '更新手机号码对应会员mapping信息失败',
self::currentMobileHasBeenBind => '当前手机号码已经绑定其他微信,如需绑定,请先手机号码登录app进行微信解绑',
self::otherDriverLogin=>'当前用户已被其他设备登录,请重新登录',
self::elasticsError=>'全文索引连接出错'
self::elasticsError=>'全文索引连接出错',
self::emptyLog => '日志内容不能为空'
);
}
......
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