2017 © Pedro Peláez
 

library understand-monolog

Understand.io Monolog package.

image

understand/understand-monolog

Understand.io Monolog package.

  • Wednesday, January 13, 2016
  • by understand
  • Repository
  • 2 Watchers
  • 2 Stars
  • 807 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Monolog Understand.io handler

Build Status Latest Stable Version Latest Unstable Version License HHVM Status Scrutinizer Code Quality, (*1)

Introduction

This package provides a Monolog handler and formatter for log data delivery to Understand.io., (*2)

You may also be interested in our Laravel 4, Laravel 5 or Laravel Lumen service provider handler, (*3)

Quick start

  1. Install package
composer require understand/understand-monolog
  1. Add an Understand handler to Monolog
use Monolog\Logger;

// input token from Understand.io
$inputToken = 'ab1cd234-1234-45e6-789f-gh1fa1234567';

// choose a handler, either async or sync (see below)
$understandAsyncHandler = new UnderstandMonolog\Handler\UnderstandAsyncHandler($inputToken); // async handler
$understandSyncHandler = new UnderstandMonolog\Handler\UnderstandSyncHandler($inputToken); // sync handler

$monologLogger = new Logger('name');
$monologLogger->pushHandler($understandAsyncHandler); // or $understandSyncHandler

$monologLogger->addError('first error');

Handlers

UnderstandSyncHandler

The sync handler uses the PHP Curl extension and delivers logs synchronously to Understand.io. This means that if your application generates a large amount of data it could slow down your app., (*4)

UnderstandAsyncHandler

We recommend making use of the async handler where possible. It is supported in most systems - the only requirement is that CURL command line tool is installed and functioning correctly. To check whether CURL is available on your system, execute the following command in your console, (*5)

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., (*6)

Exception encoder

This helper class allows you to serialize PHP exceptions as an array which can be then serialized to json. The main benefit of doing this is that Understand will then be able to parse your logs more intelligently, allowing for better search and filtering capabilities., (*7)

$exception = new \DomainException('This is Exception', 123);

$encoder = new \UnderstandMonolog\Encoder\ExceptionEncoder();
$array = $encoder->exceptionToArray($exception);

print_r($array);exit;

//Array
//(
//    [message] => This is Exception
//    [class] => DomainException
//    [code] => 123
//    [file] => /home/vagrant/share/understand-lumen-test/app/Exceptions/Handler.php
//    [line] => 30
//    [stack] => Array
//        (
//            [0] => Array
//                (
//                    [class] => App\Exceptions\Handler
//                    [function] => report
//                    [args] => Array
//                        (
//                            [0] => DomainException
//                        )
//
//                    [type] => method
//                    [file] => /home/vagrant/share/understand-lumen-test/vendor/laravel/lumen-framework/src/Application.php
//                    [line] => 354
// .......... and more

How to use the Exception encoder

use Monolog\Logger;

// input token from Understand.io
$inputToken = 'ab1cd234-1234-45e6-789f-gh1fa1234567';

// choose a handler
$understandAsyncHandler = new UnderstandMonolog\Handler\UnderstandAsyncHandler($inputToken); // async handler

$monologLogger = new Logger('name');
$monologLogger->pushHandler($understandAsyncHandler);

$exception = new \DomainException('This is Exception', 123);

$encoder = new UnderstandMonolog\Encoder\ExceptionEncoder();
$context = $encoder->exceptionToArray($exception);

$monologLogger->addError($exception->getMessage(), $context);

License

The Understand.io Monolog package is open-sourced software licensed under the MIT license, (*8)

The Versions

13/01 2016

dev-master

9999999-dev https://github.com/understand/understand-monolog

Understand.io Monolog package.

  Sources   Download

MIT

The Requires

 

The Development Requires

log logging monolog understand understand.io

27/10 2015

v1.0.0

1.0.0.0 https://github.com/understand/understand-monolog

Understand.io Monolog package.

  Sources   Download

MIT

The Requires

 

The Development Requires

log logging monolog understand understand.io

21/10 2015

v0.0.1

0.0.1.0 https://github.com/understand/understand-monolog

Understand.io Monolog package.

  Sources   Download

MIT

The Requires

 

log logging understand.io understad