2017 © Pedro Peláez
 

library dblog

Lightweight Laravel package for writing custom logs and error messages to a database.

image

supersixtwo/dblog

Lightweight Laravel package for writing custom logs and error messages to a database.

  • Monday, September 21, 2015
  • by supersixtwo
  • Repository
  • 2 Watchers
  • 4 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DBlog - Custom Laravel Logs Writer

Latest Version on Packagist ![Total Downloads][ico-downloads] ![Software License][ico-license], (*1)

DBlog is a lightweight and simple Laravel Package that allows you write custom logs and error messages to a database table., (*2)

Written to mirror the Laravel Logging conventions, DBlog provides 8 logging levels defined in RFC 5424 and the ability to add an optional context array to each log., (*3)

NOTE: This package DOES NOT integrate with the Laravel / Monolog logging system and does not capture system level events. It's purpose is to be used to capture your own custom log needs., (*4)

Installation

Via Composer:, (*5)

``` bash $ composer require supersixtwo/dblog, (*6)


Then add the service provider in `config/app.php`: ``` php Supersixtwo\Dblog\DBlogServiceProvider::class,

And the alias in config/app.php:, (*7)

``` php 'DBlog' => Supersixtwo\Dblog\DBlogClass::class,, (*8)


Re-run the autoload: ``` bash $ composer dump-autoload

Publish the migrations:, (*9)

``` bash $ php artisan vendor:publish, (*10)


Run the migrations to install the tables in the database: ``` bash $ php artisan migrate

Usage

Logging Messages

We've provided DBlog with a familiar interface, mirroring Laravel's own built-in logging methods. These follow the same RFC 5424 defined logging levels including: emergency, alert, critical, error, warning, notice, info, and debug., (*11)

Include the DBlog at the top of your class or model:, (*12)

``` php use DBlog;, (*13)


Use one of the 8 helper methods in your logic: ``` php DBlog::emergency($msg); DBlog::alert($msg); DBlog::critical($msg); DBlog::error($msg); DBlog::warning($msg); DBlog::notice($msg); DBlog::info($msg); DBlog::debug($msg);

Contextual Information

In addition to logging text based messages, you can also an array of contextual information to the logging methods. This contextual data will converted to a json array and stored in separate column., (*14)

``` php DBlog::info('New User Creation', ['id' => 45, 'created_by' => 'jdoe']);, (*15)


## DBlog Model and Table ### Model and Table Names To avoid collisions and naming conflicts with the DBlog Facade or other tables, the database table can be accessed using the following: * Model Name: `DBlogModel` * Table Name: `dblogs` ### `dblogs` Table Columns | Column | Type | Default Value | Nullable | Comments | |-------------------|------------------|-------------------|----------|------------------------------------| | id | int(10) unsigned | | NO | | | level_id | int(11) | | NO | The RFC 5424 log level id | | level_description | varchar(255) | | NO | The RFC 5424 log level description | | message | text | | NO | | | context | text | | YES | | | created_at | timestamp | CURRENT_TIMESTAMP | NO | | ### Querying the Model First, include the `DBlogModel` with the namespace: ``` php use Supersixtwo\Dblog\DBlogModel;

Then via Query Builder:, (*16)

``` php $logs = DB::table('dblogs')->get();, (*17)


or via Eloquent: ``` php $logs = DBlogModel::all();

Change log

Please see CHANGELOG for more information what has changed recently., (*18)

Contributing

Please see CONTRIBUTING for details., (*19)

Security

If you discover any security related issues, please email appsupport@supersixtwo.com instead of using the issue tracker., (*20)

Credits

License

The MIT License (MIT). Please see License File for more information., (*21)

Acknowledgements

This package is heavily inspired by the Monolog Logging Library., (*22)

The Versions

21/09 2015

dev-master

9999999-dev https://github.com/supersixtwo/dblog

Lightweight Laravel package for writing custom logs and error messages to a database.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel laravel-database laravel-logging custom-logging database-logging supersixtwo dblog

20/09 2015

v1.0.0

1.0.0.0 https://github.com/supersixtwo/dblog

Lightweight Laravel package for writing custom logs and error messages to a database.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel laravel-database laravel-logging custom-logging database-logging supersixtwo dblog