PHP code example of expdev07 / laravel-logsnag

1. Go to this page and download the library: Download expdev07/laravel-logsnag 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/ */

    

expdev07 / laravel-logsnag example snippets




return [

    /*
    |--------------------------------------------------------------------------
    | Logsnag.
    |--------------------------------------------------------------------------
    |
    | Configure the Logsnag options.
    |
    */

    /**
     * The project name.
     */
    'project' => env('LOGSNAG_PROJECT', 'laravel'),

    /**
     * The API token.
     */
    'token' => env('LOGSNAG_TOKEN', ''),

    /**
     * A mapping of icons for logging.
     */
    'icons' => [
        'DEBUG'     => 'ℹ️',
        'INFO'      => 'ℹ️',
        'NOTICE'    => '📌',
        'WARNING'   => '⚠️',
        'ERROR'     => '⚠️',
        'CRITICAL'  => '🔥',
        'ALERT'     => '🔔️',
        'EMERGENCY' => '💀',
    ],

];

'channels' => [
    //...
    'logsnag' => [
        'driver'  => 'custom',
        'via'     => ExpDev07\Logsnag\Logger\LogsnagLogger::class,
        'level'   => 'debug',
        'project' => 'my-project',
        'channel' => 'my-channel',
        'notify'  => true,         
    ],
];

use Illuminate\Support\Facades\Log;
 
Log::channel('logsnag')->emergency('There is an emergency! Please fix ASAP.');

use ExpDev07\Logsnag\Facades\Logsnag;
 
Logsnag::log('my-channel', 
    event: 'New subscriber!', 
    description: 'Someone just subscribed to MySaaS Pro at $9.99', 
    icon: '🤑', 
    notify: true,
);

use ExpDev07\Logsnag\Client\LogsnagClient;

app(LogsnagClient::class)->log(new LogsnagRequest(
    project: 'project-name',
    channel: 'channel',
    event: 'Test event',
    description: 'This is a description for test event',
    icon: '😊',
    notify: true,
));
bash
php artisan vendor:publish --tag="logsnag-config"