PHP code example of justrau / laravel-pretty-slack-logs

1. Go to this page and download the library: Download justrau/laravel-pretty-slack-logs 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/ */

    

justrau / laravel-pretty-slack-logs example snippets


use JustRau\PrettySlackLogs\Channel;

return [
    'channels' => [

        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'pretty-slack'],
            'ignore_exceptions' => false,
        ],

        'pretty-slack' => [
            'driver' => 'custom',
            'via' => Channel::class,
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'level' => env('LOG_SLACK_LEVEL', 'error'),
        ],

    ],
];

// Throws → caught by Laravel's exception handler → reported to the stack channel
throw new RuntimeException('Boom');

// Reported manually
report(new DomainException('handled but worth flagging'));

// Direct logger calls with context
Log::error('Failed to send notification', [
    'user_id' => 42,
    'channel' => 'email',
    'attempt' => 3,
]);

// Direct to this channel
Log::channel('pretty-slack')->critical('Payment processor unreachable', [
    'provider' => 'stripe',
    'amount' => 12345,
]);

LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ
LOG_SLACK_LEVEL=error