PHP code example of saasscaleup / laravel-log-alarm

1. Go to this page and download the library: Download saasscaleup/laravel-log-alarm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saasscaleup / laravel-log-alarm example snippets


Saasscaleup\LogAlarm\LogAlarmServiceProvider::class,



return [

    // enable or disable LOG ALARM
    'enabled' => env('LA_ENABLED', true),

    // log listener for specific log type
    'log_type' => env('LA_LOG_TYPE', 'error'), // also possible: 'error,warning,debug'

    // log time frame - log time frame to listen - in minutes
    "log_time_frame" => env('LA_LOG_TIME_FRAME', 1),

    // log per time frame - How many log to count per time frame until alarm trigger 
    "log_per_time_frame" => env('LA_LOG_PER_TIME_FRAME', 5),

    // delay between alarms in minutes - How many minutes to delay between alarms
    'delay_between_alarms' => env('LA_DELAY_BETWEEN_ALARMS', 5),

    // log listener for specific word inside log messages
    'specific_string' => env('LA_SPECIFIC_STRING', ''), // also possible: 'table lock' or 'foo' or 'bar' or leave empty '' to enable any word

    // notification message for log alarm
    'notification_message' => env('LA_NOTIFICATION_MESSAGE', 'Log Alarm got triggered!'),
    
    // Slack webhook url for log alarm
    'slack_webhook_url' => env('LA_SLACK_WEBHOOK_URL', ''),

    // notification email address for log alarm
    'notification_email' => env('LA_NOTIFICATION_EMAIL', '[email protected],[email protected]'),

    // notification email subject for log alarm
    'notification_email_subject' => env('LA_NOTIFICATION_EMAIL_SUBJECT', 'Log Alarm Notification'),
];
bash
php artisan vendor:publish --provider="Saasscaleup\LogAlarm\LogAlarmServiceProvider"

php artisan tinker

LA_ENABLED=true
LA_LOG_TYPE=error
LA_LOG_TIME_FRAME=1
LA_LOG_PER_TIME_FRAME=5
LA_DELAY_BETWEEN_ALARMS=5
LA_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/your/webhook/url
[email protected]
LA_NOTIFICATION_EMAIL_SUBJECT="Log Alarm Notification"