2017 © Pedro Peláez
 

library laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

image

itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  • Thursday, May 3, 2018
  • by itelmenko
  • Repository
  • 1 Watchers
  • 1 Stars
  • 233 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 276 % Grown

The README.md

Laravel Monolog MySQL Handler.

This package will log errors into MySQL database instead storage/log/laravel.log file., (*1)

Installation

composer require itelmenko/laravel-mysql-logger

For Laravel earlier than 10.0, please use version 1.0.7 of this package.:, (*2)

composer require itelmenko/laravel-mysql-logger:v1.0.7

If you wish to change default table name to write the log into or database connection use following definitions in your .env file, (*3)

DB_LOG_TABLE=logs
DB_LOG_CONNECTION=mysql

For Laravel < 5.5 open up config/app.php and find the providers key., (*4)

'providers' => array(
    // ...
    ITelmenko\Logger\Laravel\Providers\MonologMysqlHandlerServiceProvider::class,
);

In config/logging.php, (*5)

<?php
    // [...]

    'channels' => [

        // [...]

        'mysql' => [
            'driver' => 'custom',
            'via' => ITelmenko\Logger\Laravel\Logging\MySQLLogger::class,
            'connection' => env('DB_LOG_CONNECTION'),
            'table' => env('DB_LOG_TABLE'),
            'name' => 'my.channel' // optional
        ],
    ],

Publish config using Laravel Artisan CLI., (*6)

php artisan vendor:publish

and select the option Provider: ITelmenko\Logger\Laravel\Providers\MonologMysqlHandlerServiceProvider, (*7)

Migrate tables., (*8)

php artisan migrate

Add ITelmenko\Logger\Laravel\Exceptions\MysqlLoggerInsertException into your ExceptionHandler to prevent looping when a database connection fails:, (*9)

public function register()
{
    $this->reportable(function (Throwable $e) {
        if ($this->shouldReport($e) && app()->bound('sentry')) {
            app('sentry')->captureException($e);
        }
        if ($e instanceof MysqlLoggerInsertException) {
            return false; // prevent looping 
        }
    });
}

Using

Somewhere in your application

Log::channel('mysql')->info('Something happened!');

TODO

  • ~~Change $table->bigIncrements('id') to something like ULID~~
  • ~~Change root namespace to~~ ITelmenko
  • ~~Remove extra fields from model~~
  • ~~Remove updated_at?~~
  • ~~Add microseconds for created_at~~
  • Update version and readme.md (about a changing of migration, about vendor:publish)
  • Add php doc
  • Add phpcs

The Versions

03/05 2018

dev-master

9999999-dev https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

03/05 2018

v0.1.8

0.1.8.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.7

0.1.7.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.6

0.1.6.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.5

0.1.5.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.4

0.1.4.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.3

0.1.3.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.2

0.1.2.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6

02/05 2018

v0.1.1

0.1.1.0 https://github.com/itelmenko/laravel-mysql-logger

Laravel 5.6+ MySQL driver for Monolog

  Sources   Download

MIT

The Requires

  • php >=7.1.4

 

by Igor Telmenko

laravel log monolog mysql laravel5.6