GithubHelp home page GithubHelp logo

laravel-query-logger's Introduction

Laravel Query Logger

📝 A dev tool to log all queries for Laravel application.

Sponsor me

Installing

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

Laravel Query Logger will be enabled when LOG_QUERY is true.

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:

config/logging.php:

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'), 
        
        // Log Channel
        'channel' => 'stack',
    ],
];

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

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

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

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

License

MIT

laravel-query-logger's People

Contributors

bolechen avatar dependabot-preview[bot] avatar guanguans avatar iwindy avatar laravel-shift avatar osindex avatar overtrue avatar ruchengtang avatar seekerliu avatar summerblue avatar yl20181120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-query-logger's Issues

PHP RFC: Escape PDO "?" parameter placeholder

I'm having issue with laravel-query-logger when working from Laravel with PostgreSQL and I need to escape "?" operator, example:

DB::table('table_name')->whereRaw('jsonb_column ?? ?', ['key'])->get();

This code allows me to check if specific key exists in jsonb column type, but laravel-query-logger throws exception:
{"exception":{"class":"ValueError","message":"The arguments array must contain 3 items, 1 given","code":0,"file":"/app/vendor/overtrue/laravel-query-logger/src/ServiceProvider.php:49"}}

Escaping is described here:
https://wiki.php.net/rfc/pdo_escape_placeholders

PR: #28

[Pull Request] 支持Laravel 5.1

这个插件很赞,我有个老项目使用Laravel5.1,一时半会可能不会升级,因此我照着这个插件改了一下支持Laravel5.1,如果可以的话我会推一个PR上来。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.