2017 © Pedro Peláez
 

library reporter

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

image

bkwld/reporter

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  • Wednesday, April 5, 2017
  • by weotch
  • Repository
  • 4 Watchers
  • 24 Stars
  • 11,136 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 21 Versions
  • 3 % Grown

The README.md

Reporter

Reporter is a package for Laravel 5 (versions 3.x) and Laravel 4 (versions 2.x) that brings back functionality found in the profiler of Laravel 3. Instead of displaying output in the browser, it writes to the disk in a log file that you can watch in realtime with tail -f or an app like Mac's Console. This adds some advantages over a browser based profiler:, (*1)

  • You can inspect AJAX requests
  • POST variables are logged
  • The output rendering isn't affected by your application's CSS or JS
  • You can inspect apps that are in a production environment

The output looks like:, (*2)

---------------------------------------------------------------------
1/28/16 1:21:09 AM

REQUEST:   /admin/articles/19/edit?search=example
TIME:      111.46ms
TIMERS:    
  example: 2.36ms
MEMORY:    14 MB (PEAK: 14 MB)
INPUT:     
  search: example
SQL:       5 queries
  (0.46 ms) select * from `admins` where `admins`.`id` = '1' limit 1
  (0.30 ms) select * from `articles` where `articles`.`id` = '19' limit 1
  (0.44 ms) select * from `images` where `images`.`imageable_id` in ('19') and
            `images`.`imageable_type` = 'App\Article'
  (0.49 ms) select * from `articles` where `articles`.`id` = '19' limit 1
  (0.43 ms) select * from `images` where `images`.`imageable_id` in ('19') and
           `images`.`imageable_type` = 'App\Article'

INFO:      Hey, make sure to wear pants

Or, if you have style turned on:, (*3)

image, (*4)

Reporter also adds the ability to time blocks of code (as displayed in the examples "TIMERS" line)., (*5)

Installation

  1. Add Reporter to composer.json: "bkwld/reporter": "~3.0", and do a composer install.
  2. Add 'Bkwld\Reporter\ServiceProvider', to your app/config/app.php's providers array.
  3. If you plan to use timers, add 'Timer' => 'Bkwld\Reporter\Facades\Timer', to the app/config/app.php's aliases array.

Config

  • enable - If false, Reporter will do nothing. By default, this is set to false for the "production" enviornment IF you publish the package's config file to your app/config directory.
  • style - Add color and style codes for output in a Terminal.
  • error_log - If true, also write logs to the PHP error_log()
  • levels - An array of log levels that should be shown
  • ignore - A regex string. If the request path matches, no log will be written.

Usage

Logging

Reporter writes it's log to app/storage/logs/reporter.log. I'd recommend running tail -f storage/logs/reporter.log from your project directory to follow it., (*6)

Timer

Laravel 3 had a way to time events with it's profiler. Reporter re-introduces this., (*7)

Timer::start('example');
// Some code that you are benchmarking
Timer::stop('example');

Start() and stop() take a string as their argument that is used to match up the start and stop calls. It is also displayed as the key for the timer in the log. The above example would add lines like this to the log:, (*8)

TIMERS:
  example: 20.02ms

The Versions

05/04 2017

dev-master

9999999-dev

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

05/04 2017

3.1.0

3.1.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

24/01 2017

3.0.3

3.0.3.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

03/02 2016

3.0.2

3.0.2.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

02/02 2016

3.0.1

3.0.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

02/02 2016

3.0.0

3.0.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

10/10 2014

2.5.0

2.5.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

07/08 2014

2.4.1

2.4.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

26/06 2014

2.4.0

2.4.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

28/01 2014

2.3.1

2.3.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

28/01 2014

2.3.0

2.3.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

15/11 2013

2.2.3

2.2.3.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

06/11 2013

2.2.2

2.2.2.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

25/10 2013

2.2.1

2.2.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

23/10 2013

2.2.0

2.2.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

23/10 2013

2.1.3

2.1.3.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

11/09 2013

2.1.2

2.1.2.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

16/08 2013

2.1.1

2.1.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

29/07 2013

2.1.0

2.1.0.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

19/07 2013

2.0.1

2.0.1.0

Generate styled logs of Laravel 4 requests that include application timing, memory usage, input data, and sql queries

  Sources   Download

MIT

The Requires

 

by Robert Reinhard

15/07 2013

2.0.0

2.0.0.0

Dump diagnostic info from Laravel to the disk

  Sources   Download

MIT

The Requires

 

by Robert Reinhard