2017 © Pedro Peláez
 

library laravel-query-logger

A dev tool to log all queries for laravel application.

image

overtrue/laravel-query-logger

A dev tool to log all queries for laravel application.

  • Wednesday, June 20, 2018
  • by overtrue
  • Repository
  • 2 Watchers
  • 65 Stars
  • 2,209 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 4 Versions
  • 116 % Grown

The README.md

Laravel Query Logger

:pencil: A dev tool to log all queries for Laravel application., (*1)

Sponsor me, (*2)

Installing

$ composer require overtrue/laravel-query-logger -vvv

Laravel Query Logger will be enabled when LOG_QUERY is true., (*3)

Usage

$ tail -f ./storage/logs/laravel.log
[2017-09-05 14:52:14] local.DEBUG: [800μs] select count(*) as aggregate from `discussions` where `discussions`.`deleted_at` is null | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [1.07ms] select * from `discussions` where `discussions`.`deleted_at` is null order by `is_top` desc, `created_at` desc limit 15 offset 0 | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [3.63s] select `tags`.*, `taggables`.`taggable_id` as `pivot_taggable_id`, `taggables`.`tag_id` as `pivot_tag_id` from `tags` inner join `taggables` on `tags`.`id` = `taggables`.`tag_id` where `taggables`.`taggable_id` in ('1', '2', '3', '4', '5', '6', '7', '8') and `taggables`.`taggable_type` = 'App\\Models\\Discussion' order by `order_column` asc | GET: http://laravel.app/discussions
[2017-09-05 14:52:14] local.DEBUG: [670μs] select * from `users` where `users`.`id` in ('1', '2', '4') and `users`.`deleted_at` is null | GET: http://laravel.app/discussions
...

Configuration

You can also control whether to log a query via the configuration file:, (*4)

config/logging.php:, (*5)

return [
    //...
    'query' => [
        'enabled' => env('LOG_QUERY', env('APP_ENV') === 'local'),

        // Only record queries that are slower than the following time
        // Unit: milliseconds
        'slower_than' => 0,

        // Only record queries when the QUERY_LOG_TRIGGER is set in the environment, 
        // or when the trigger HEADER, GET, POST, or COOKIE variable is set.
        'trigger' => env('QUERY_LOG_TRIGGER'),

        // Except record queries
        'except' => [
            // '*_telescope_*',
        ],

        // Log Channel
        'channel' => 'stack',
    ],
];

:heart: Sponsor me

Sponsor me, (*6)

如果你喜欢我的项目并想支持它,点击这里 :heart:, (*7)

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects., (*8)

, (*9)

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?, (*10)

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》, (*11)

License

MIT, (*12)

The Versions

20/06 2018

dev-master

9999999-dev

A dev tool to log all queries for laravel application.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

20/06 2018

1.0.2

1.0.2.0

A dev tool to log all queries for laravel application.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

11/10 2017

1.0.1

1.0.1.0

A dev tool to log all queries for laravel application.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

07/09 2017

1.0.0

1.0.0.0

A dev tool to log all queries for laravel application.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue