Last active
          January 8, 2019 15:21 
        
      - 
      
 - 
        
Save kapv89/5561365 to your computer and use it in GitHub Desktop.  
    Log Queries in L4
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| Event::listen('illuminate.query', function($query, $bindings, $time) { | |
| static $count; | |
| if(App::make('env') === 'local') | |
| { | |
| $logFile = __DIR__.'/../storage/logs/queries'; | |
| ob_start(); | |
| var_dump($bindings, $query); | |
| $str = ob_get_clean(); | |
| if($count === null) | |
| { | |
| File::put($logFile, ''); | |
| $count = 1; | |
| } | |
| $msg = $count++ . '---------------------------------------'.PHP_EOL; | |
| $msg .= $str.PHP_EOL; | |
| $msg .= '--------------------------------------------------------------'.PHP_EOL.PHP_EOL; | |
| File::append($logFile, $msg); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Put this in
app/start/global.php, and you can view the query-log for a request-response cycle inapp/storage/logs/queries