gazatem / glog
A Laravel package, helps to log into database and send email alerts
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=5.5.0
- illuminate/support: 5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0
- monolog/monolog: ^1.23|^2.0
This package is auto-updated.
Last update: 2024-09-29 04:25:46 UTC
README
Glog helps your team monitoring your application log. Glog works with Monolog to handle the logs. But with a custom configuration,
you can save logs to database using custom rules and channels. Custom channel and log levels triggers the log alerting system and send alerts to target email addresses.
Also Glog provides a custom administrator panel to analyze the logs. Panel uses Laravel main authentication system, so you do not need to protect log control panel.
Glog supports MongoDB and mySQL. If your project needs to store more logs, you may use MongoDB. For small projects, mysql is enough to manage the logs.
Complete documentation can be found at Wiki
Installation
To get started, use Composer to add the package to your project's dependencies:
composer require gazatem/glog
Laravel 5.8 Installation Guide (includes 5.5 and newer versions)
If you're using a later version of Laravel 5.5, service provider will automatically get registered. For older versions you need to do it your self.
Open config/logging.php and add following array item to configuration file:
'glog' => [ 'driver' => 'monolog', 'handler' => \Gazatem\Glog\Glog::class, ],
And later do not forget to modify stack and add glog to stack. That is first item of configuration:
'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'glog'], ],
Laravel 5.4 and earlier versions Installation Guide
Open your config/app.php add following line in the providers array
Gazatem\Glog\Providers\GlogServiceProvider::class
Then in your bootstrap/app.php add / update your Monolog configuration.
$app->configureMonologUsing(function ($monolog) { $monolog->pushHandler(new \Gazatem\Glog\Glog()); });
Mail Alert System
Additionally add the listener to your app/Providers/EventServiceProvider.php:
\Gazatem\Glog\Events\MailLog::class => [ \Gazatem\Glog\Listeners\MailListener::class, ],
Publish settings
Run following command to publish migration and configuration
php artisan vendor:publish --provider="Gazatem\Glog\Providers\GlogServiceProvider"
Migration
To create database tables, run migration:
php artisan migrate
That's all now, now let's start to log the events.
Configuration
All system configuration is under config folder inside glog.php file. This file simply store system configuration. Add custom channels, update database and route of the control panel.
<?php return [ // No need to change it now, thats for future releases! 'service' => env('GLOG_SERVICE', 'local'), // Secure your log panel 'middlewares' => ['web', 'App\Http\Middleware\LogAccess'], // glog uses mysql default, but can be choose mongodb 'db_connection' => env('DB_CONNECTION', 'mysql'), // To create an alert, enter level and channel pair here // Example: 'notification' => ['test-channel' => ['CRITICAL', 'ALERT']], 'notification' => [], 'mail_subject' => 'Glog notification mail', 'mail_to' => env('MAIL_FROM'), 'translations' => [ 'test-channel' => 'A sample channel' ], // Panel route path 'route-prefix' => 'logs-panel', // All channels must be entered before to send the API. 'levels' => ['EMERGENCY', 'ALERT', 'CRITICAL', 'ERROR', 'WARNING', 'NOTICE', 'INFO', 'DEBUG'], 'channels' => ['test-channel', 'user.register'], ];
Usage
Do not fotget to include Log to your class.
use Log;
And add some log entries:
Log::info('user.register', ['message' => 'User Registration Controller', 'id' => 23, 'name' => 'John Doe', 'email' => 'john@example.com']);