PHP code example of shadowbane / laravel-datadog-logger

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

    

shadowbane / laravel-datadog-logger example snippets


'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'datadog-api'],
    ],
]

use Illuminate\Support\Facades\Log;

Log::channel('datadog-api')->info('User logged in', [
    'user_id' => 123,
    'ip_address' => '192.168.1.1',
]);

Log::channel('datadog-api')->error('Payment failed', [
    'order_id' => 456,
    'amount' => 99.99,
]);

try {
    // Your code
} catch (\Exception $e) {
    Log::channel('datadog-api')->error('Failed to create company: ' . $e->getMessage(), [
        'exception' => $e,
        'company_id' => 123,
        'user_id' => 456,
    ]);
}

Log::channel('datadog-api')->warning('High memory usage', [
    'memory_used' => '512MB',
    'memory_limit' => '256MB',
    'server' => 'web-01',
]);
bash
php artisan datadog:send-test-exception