Fork me on GitHub

Usage

Before to start logging, please make sure that system setup completed and working correctly!

Do not fotget to include Log to your library to your code:
use Log;

A sample usage in a controller:
    namespace App\Http\Controllers;  

    use Log;   
    
    class ReportController extends Controller
    {
        public function getDailyStat()
        {
            Log::info('log', ['message' = 'Report service called', method='getDailyStat']);
            return view('report/daily-stat');
        }
    }

Configuration

This is hearth of Glog. Therefore please, double notice this part of documantation. Here is the sample config file coming with default settings.

config/glog.php



return [

    'service' => 'local',

    'db_connection' => 'mysql',
    
    'auth'  => 'true',

    'levels' => ['EMERGENCY', 'ALERT', 'CRITICAL', 'ERROR', 'WARNING', 'NOTICE', 'INFO', 'DEBUG'],

    'channels' => ['blog-home', 'blog-post', 'blog-category', 'user-login'],

    'notification' => [],

    'mail_subject' => 'gLog notification mail',

    'mail_to' => env('MAIL_FROM'),

    'translations' => [
        'action.failed' => 'Action failed',
        'user.register' => 'A new user registered',
        'log' => 'LOG',
    ],
    
    'route-prefix' => 'logs',
];

    

If you can not find this file (glog.php) under config folder, this means that you've failed to publish vendor. Please, check the installation steps again.

Service config: Local or Api

Current release, works on local. So default choice is local. Ne need to change it. But in next days, we will publish an api gateaway to log remote. So leave it as comes default.


Log Levels

Same as laravel do, the logger provides the eight logging levels defined in RFC 5424: emergency, alert, critical, error, warning, notice, info and debug. If you do not log any level, remove it from levels array.


Channels

These are the hooks which our log handler will take care of them with levels. If you log with a level and settings channel as a message in log instance, system will handle it.


Some examples:


    Log::info('blog-post', ['message' => 'Blog post has been seen!']);
    
    Log::debug('blog-post', ['message' => 'Post has been viewd']);



Notification

If you log using a channel with described level in notification array, it triggers mailing system. An example will cover it better:

Example with notification:


    Log::critical('user.fail');

In this example, our target channel is user.fail and it's also in our notification array. In notification array, user.fail has two log levels: ['CRITICAL', 'ALERT'] So if we loog user.fail with critiacal or alert level, dblogger will send an alert mail with exception message, remote ip address.

Another example without notification:


    Log::debug('user.fail');

In this example, our target channel is user.fail and it's also in our notification array. But target level is debug which is not in our notification level. So system will not mail anything.

Mail Settings
You may update your email subject and target email. But also you may exchange channels name to a custom messages. instead of user.fail 'A new user registered' will be a better message in email. Also if you use GUI within the same setup (or you can copy it to Gui setup), Gui will show pretty messages instead of short name.


Web-Based Panel
Default Loga Panel can be accessible at http://your-site/logs. However you may change this URL from glog config page.