2017 © Pedro Peláez
 

library understand-laravel5

Laravel 5 service provider for Understand.io

image

understand/understand-laravel5

Laravel 5 service provider for Understand.io

  • Friday, May 11, 2018
  • by understand
  • Repository
  • 2 Watchers
  • 12 Stars
  • 71,334 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 27 Versions
  • 10 % Grown

The README.md

Laravel 5, 6, 7, 8, 9, 10, 11 and 12 integration for Understand.io

Latest Version on Packagist Quality Score Total Downloads, (*1)

Introduction

This packages provides a full abstraction for Understand.io and provides extra features to improve Laravel's default logging capabilities. It is essentially a wrapper around Laravel's event handler to take full advantage of Understand.io's data aggregation and analysis capabilities., (*2)

Quick start

  1. Add the package to your project
composer require understand/understand-laravel
  1. Add the ServiceProvider to the providers array in config/app.php
Understand\UnderstandLaravel5\UnderstandLaravel5ServiceProvider::class,
  1. Set your Understand.io input token in your .env file
UNDERSTAND_ENABLED=true
UNDERSTAND_TOKEN=your-input-token-from-understand-io
  1. Send your first error
// anywhere inside your Laravel app
\Log::error('Understand.io test error');

How to send events/logs

Laravel logs

By default, Laravel automatically stores its logs in storage/logs. By using this package, your log data will also be sent to your Understand.io channel. This includes error and exception logs, as well as any log events that you have defined (for example, Log::info('my custom log'))., (*3)

\Log::info('my message', ['my_custom_field' => 'my data']);

PHP/Laravel exceptions

By default, all errors and exceptions with code fragments and stack traces will be sent to Understand.io., (*4)

The following extra information will be collected:, (*5)

Type Default Config Key Config Options
SQL queries Enabled UNDERSTAND_SQL= true or false
SQL query values/bindings Disabled UNDERSTAND_SQL_BINDINGS= true or false
HTTP request query string data Enabled UNDERSTAND_QUERY_STRING= true or false
HTTP request form or JSON data Enabled UNDERSTAND_POST_DATA= true or false

Additionally, you can specify which HTTP request field values should not be sent to Understand.io. By default, the following field values will be hidden:, (*6)

UNDERSTAND_HIDDEN_REQUEST_FIELDS=password,password_confirmation,access_token,secret_key,token,access_key

If you wish you can publish the configuration file and make desired adjustments. See Advanced configuration, (*7)

How to send data asynchronously

Async handler

By default each log event will be sent to Understand.io's api server directly after the event happens. If you generate a large number of logs, this could slow your app down and, in these scenarios, we recommend that you make use of an async handler. To do this, set the config parameter UNDERSTAND_HANDLER to async in your .env file., (*8)

# Specify which handler to use - sync, queue or async. 
# 
# Note that the async handler will only work in systems where 
# the CURL command line tool is installed
UNDERSTAND_HANDLER=async

The async handler is supported in most systems - the only requirement is that the CURL command line tool is installed and functioning correctly. To check whether CURL is available on your system, execute following command in your console:, (*9)

curl -h

If you see instructions on how to use CURL then your system has the CURL binary installed and you can use the async handler., (*10)

Keep in mind that Laravel allows you to specify different configuration values in different environments. You could, for example, use the async handler in production and the sync handler in development., (*11)

How to report Laravel 5.0 (>= 5.0, < 5.1) exceptions

Laravel's (>= 5.0, < 5.1) exception logger doesn't use event dispatcher (https://github.com/laravel/framework/pull/10922) and that's why you need to add the following line to your Handler.php file (otherwise Laravel's exceptions will not be sent Understand.io)., (*12)

  • Open app/Exceptions/Handler.php and put this line \UnderstandExceptionLogger::log($e) inside report method., (*13)

    public function report(Exception $e)
    {
      \UnderstandExceptionLogger::log($e);
    
      return parent::report($e);
    }
    

Advanced Configuration

  1. Publish configuration file
php artisan vendor:publish --provider="Understand\UnderstandLaravel5\UnderstandLaravel5ServiceProvider"

Log Filter

To filter out specific log types a custom log filter can be provided., (*14)

Example filter class, (*15)

// app/Logging/UnderstandLogFilter.php
<?php

declare(strict_types=1);

namespace App\Logging;

use Illuminate\Support\Str;

class UnderstandLogFilter
{
    public function __invoke($level, $message, $context): bool
    {
        if ($level === 'warning' && Str::contains(strtolower($message), 'deprecated')) {
            return true;
        }

        return false;
    }
}

and then it can be configured in understand-laravel.php, (*16)

<?php
// ...
// config/understand-laravel.php
'log_filter' => \App\Logging\UnderstandLogFilter::class,

The log_filter config value must be a callable type: - https://www.php.net/manual/en/function.is-callable.php
or a callable dependency from the service container: - https://laravel.com/docs/9.x/container#the-make-method, (*17)

The suggested way would be to create an invokable class since it's hard to serialise anonymous functions (Laravel config cache): - https://www.php.net/manual/en/language.oop5.magic.php#object.invoke, (*18)

The log filter interface must be as follows: $callable($level, $message, $context). The result of the filter must be a boolean value: - TRUE, the log should be ignored and NOT delivered to Understand.io - FALSE, the log should be delivered to Understand.io, (*19)

The ignored_logs config value has higher precedence than log_filter., (*20)

Requirements

UTF-8

This package uses the json_encode function, which only supports UTF-8 data, and you should therefore ensure that all of your data is correctly encoded. In the event that your log data contains non UTF-8 strings, then the json_encode function will not be able to serialize the data., (*21)

http://php.net/manual/en/function.json-encode.php, (*22)

License

The Laravel Understand.io service provider is open-sourced software licensed under the MIT license, (*23)

The Versions

11/05 2018

dev-master

9999999-dev

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand understand.io

11/05 2018

v2.0.6

2.0.6.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

18/04 2018

v2.0.5

2.0.5.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

05/04 2018

v2.0.4

2.0.4.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

29/03 2018

dev-query-count-test-fix

dev-query-count-test-fix

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

14/03 2018

v2.0.3

2.0.3.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

13/02 2018

v2.0.2

2.0.2.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

06/02 2018

v2.0.1

2.0.1.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

06/02 2018

0.0.x-dev

0.0.9999999.9999999-dev

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

30/01 2018

2.0.x-dev

2.0.9999999.9999999-dev

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

25/01 2018

v2.0

2.0.0.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs understand understand.io

25/01 2018

v0.0.16

0.0.16.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

05/04 2017

v0.0.15

0.0.15.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

27/03 2017

v0.0.14

0.0.14.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

20/03 2017

v0.0.13

0.0.13.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

14/03 2017

v0.0.12

0.0.12.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

29/01 2017

v0.0.11

0.0.11.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

16/12 2016

v0.0.10

0.0.10.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

16/12 2016

v0.0.9

0.0.9.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

07/12 2016

v0.0.8

0.0.8.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

13/01 2016

v0.0.7

0.0.7.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

10/01 2016

v0.0.6

0.0.6.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

09/06 2015

v0.0.5

0.0.5.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

11/05 2015

v0.0.4

0.0.4.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

08/05 2015

v0.0.3

0.0.3.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

28/04 2015

v0.0.2

0.0.2.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand

25/03 2015

v0.0.1

0.0.1.0

Laravel 5 service provider for Understand.io

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

by Avatar aivis

laravel laravel 5 logs undertstand.io understand