定制 sunaoka/laravel-query-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunaoka/laravel-query-logger

最新稳定版本:v2.1.2

Composer 安装命令:

composer require --dev sunaoka/laravel-query-logger

包简介

Query logger for Laravel.

README 文档

README

Latest Stable Version License PHP from Packagist Laravel Test codecov

Support Policy

Version (*1) Laravel (*2) PHP (*3)
1 5.7 - 11 7.1 - 8.3
2 10.15 - 12 8.1 - 8.5

(*1) Supported Query logger version

(*2) Supported Laravel versions

(*3) Supported PHP versions

Installation

composer require --dev sunaoka/laravel-query-logger

Configurations

php artisan vendor:publish --tag=query-logger-config
<?php

declare(strict_types=1);

return [

    /*
    |--------------------------------------------------------------------------
    | Output Log Color
    |--------------------------------------------------------------------------
    |
    | Sets the foreground and background colors of the log output.
    |
    | Supported: "black", "red", "green", "yellow", "blue", "magenta", "cyan",
    |            "white", "default", "gray", "bright-red", "bright-green",
    |            "bright-yellow", "bright-blue", "bright-magenta",
    |            "bright-cyan", "bright-white"
    */

    'color' => [
        'foreground' => env('QUERY_LOGGER_COLOR_FOREGROUND', ''),
        'background' => env('QUERY_LOGGER_COLOR_BACKGROUND', ''),
    ],

    /*
    |--------------------------------------------------------------------------
    | Slow Query Log
    |--------------------------------------------------------------------------
    |
    | Sets the number of milliseconds to output the slow query.
    | If less than 0 is specified, all logs are output.
    */

    'slow_query' => [
        'milliseconds' => (int) env('QUERY_LOGGER_SLOW_QUERY_MILLISECONDS', 0),
    ],
];

Usage

<?php

\DB::beginTransaction();
\App\User::whereEmail('example@example.com')->update(['name' => 'example']);
\DB::commit();

\DB::beginTransaction();
\App\User::whereEmail('example@example.com')->update(['name' => 'example']);
\DB::rollBack();
tail -F storage/logs/laravel.log
[2020-09-11 01:08:37] local.DEBUG: BEGIN;  
[2020-09-11 01:08:37] local.DEBUG: [0.31ms] update "users" set "name" = 'example' where "email" = 'example@example.com';  
[2020-09-11 01:08:37] local.DEBUG: COMMIT;  

[2020-09-11 01:08:37] local.DEBUG: BEGIN;  
[2020-09-11 01:08:37] local.DEBUG: [0.12ms] update "users" set "name" = 'example' where "email" = 'example@example.com';  
[2020-09-11 01:08:37] local.DEBUG: ROLLBACK;  

统计信息

  • 总下载量: 918
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-13