adrianoalves/laravel-exceptionlog

Simple Laravel Exception and Error Persistence Log Layer

Installs: 25

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:laravel-package

v1.1.0 2020-03-30 03:14 UTC

This package is auto-updated.

Last update: 2024-11-24 12:59:50 UTC


README

Simplest/Minimum Laravel Exception Log Persistence Layer Package

Installation

Use composer require adrianoalves/laravel-exceptionlog to install the package.

Execute php artisan migrate to create the logs database table

How to Use

Just call the following Method in your application:

try{
  // ... put your watched code here
}
catch( \Exception $exception ){
    ExceptionLog::persist( $exception, ExceptionLog\LevelMapper::LEVEL_ERROR_APPLICATION );
}

It is simple as pie :)

Log Levels

The package has a much simple mapper to organize exceptions in levels/categories.

const LEVEL_NOTICE            = 1;

    const LEVEL_WARNING           = 2;

    const LEVEL_ERROR_APPLICATION = 3;

    const LEVEL_ERROR_DATABASE    = 4;

    const LEVEL_ERROR_SERVER      = 5;

    const LEVEL_ERROR_CONSOLE     = 6;

    const LEVEL_ERROR_JOB         = 7;

    public static $mapper = [
        1 => [ 'label' => 'Notificação' ],
        2 => [ 'label' => 'Aviso' ],
        3 => [ 'label' => 'Erro: Sistema' ],
        4 => [ 'label' => 'Erro: Persistência' ],
        5 => [ 'label' => 'Erro: Servidor' ],
        6 => [ 'label' => 'Erro: Console' ],
        7 => [ 'label' => 'Erro: Execução de Job' ],
    ];

You can create and customize your own levels and dictionaries to better identify your application Exceptions.