diff --git a/app/controller/admin/user/UserGroup.php b/app/controller/admin/user/UserGroup.php index bcc018b..a84fa5e 100644 --- a/app/controller/admin/user/UserGroup.php +++ b/app/controller/admin/user/UserGroup.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)); } diff --git a/config/database.php b/config/database.php index 2634d53..3778cb7 100644 --- a/config/database.php +++ b/config/database.php @@ -61,7 +61,7 @@ return [ // 是否需要断线重连 'break_reconnect' => true, // 监听SQL - 'trigger_sql' => env('app_debug', true), + 'trigger_sql' => true, // 开启字段缓存 'fields_cache' => false, // 字段缓存路径 diff --git a/config/log.php b/config/log.php index 1c7215f..4e6f4cf 100644 --- a/config/log.php +++ b/config/log.php @@ -19,7 +19,7 @@ return [ // 日志记录级别 'level' => ['error', 'warning', 'info', 'fail', 'success'], // 日志类型记录的通道 ['error'=>'email',...] - 'type_channel' => [], + 'type_channel' => ['sql' => 'file'], // 关闭全局日志写入 'close' => false, // 全局日志处理 支持闭包 @@ -35,7 +35,7 @@ return [ // 单文件日志写入 'single' => false, // 独立日志级别 - 'apart_level' => ['error','warning','info', 'fail', 'success','sql'], + 'apart_level' => ['error', 'warning', 'info', 'fail', 'success', 'sql'], // 最大日志文件数量 'max_files' => 30, // 使用JSON格式记录 @@ -48,9 +48,12 @@ return [ 'format' => '[%s][%s] %s', // 是否实时写入 'realtime_write' => true, - 'file_size' => 1024*1024*10, + 'file_size' => 1024 * 1024 * 10, + ], + 'sql' => [ + // 日志记录方式 + 'type' => 'File', ], - // 其它日志通道配置 ], ]; diff --git a/config/swoole.php b/config/swoole.php index 8429e47..34e2ad4 100644 --- a/config/swoole.php +++ b/config/swoole.php @@ -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' => [ diff --git a/crmeb/utils/SqlLogHandle.php b/crmeb/utils/SqlLogHandle.php new file mode 100644 index 0000000..717f555 --- /dev/null +++ b/crmeb/utils/SqlLogHandle.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- +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; + } + + +}