修改配置文件

main v0.0.1
fengxinyhyl 9 months ago
parent f44fdd5e49
commit 57955edf22
  1. 2
      app/controller/admin/user/UserGroup.php
  2. 2
      config/database.php
  3. 7
      config/log.php
  4. 2
      config/swoole.php
  5. 41
      crmeb/utils/SqlLogHandle.php

@ -22,6 +22,7 @@ use think\App;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Log;
/**
* Class UserGroup
@ -60,6 +61,7 @@ class UserGroup extends BaseController
[$page, $limit] = $this->getPage();
$where = array();
$where[] = ['group_id', '>', 1];
Log::info(json_encode($where));
return app('json')->success($this->repository->getList($where, $page, $limit));
}

@ -61,7 +61,7 @@ return [
// 是否需要断线重连
'break_reconnect' => true,
// 监听SQL
'trigger_sql' => env('app_debug', true),
'trigger_sql' => true,
// 开启字段缓存
'fields_cache' => false,
// 字段缓存路径

@ -19,7 +19,7 @@ return [
// 日志记录级别
'level' => ['error', 'warning', 'info', 'fail', 'success'],
// 日志类型记录的通道 ['error'=>'email',...]
'type_channel' => [],
'type_channel' => ['sql' => 'file'],
// 关闭全局日志写入
'close' => false,
// 全局日志处理 支持闭包
@ -50,7 +50,10 @@ return [
'realtime_write' => true,
'file_size' => 1024 * 1024 * 10,
],
// 其它日志通道配置
'sql' => [
// 日志记录方式
'type' => 'File',
],
],
];

@ -17,7 +17,7 @@ use think\swoole\websocket\socketio\Parser;
return [
'server' => [
'host' => env('SWOOLE_HOST', '0.0.0.0'), // 监听地址
'port' => env('SWOOLE_PORT', 8324), // 监听端口
'port' => env('SWOOLE_PORT', 8325), // 监听端口
'mode' => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS
'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP
'options' => [

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2021 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace crmeb\utils;
use think\contract\LogHandlerInterface;
use think\facade\Log;
/**
* 本地化调试输出到文件
*/
class SqlLogHandle implements LogHandlerInterface
{
/**
* 日志写入接口
* @access public
* @param array $log 日志信息
* @return bool
*/
public function save(array $log): bool
{
$logArray = array_chunk($log['sql'], 10);
foreach ($logArray as $array) {
// Log::write('sql', 'info', $array);
Log::write('sql', 'info');
// Logger::getLogger()->system(false)->info('SqlLogHandle', $array);
}
return true;
}
}
Loading…
Cancel
Save