PHP code example of codexpedite / laravel-supabase-logger

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

    

codexpedite / laravel-supabase-logger example snippets


'channels' => [
    // ... other channels

    'supabase' => [
        'driver' => 'custom',
        'via' => \Codexpedite\LaravelSupabaseLogger\SupabaseLoggerCreator::class,
        'level' => env('LOG_LEVEL', 'debug'),
    ],
],

use Illuminate\Support\Facades\Log;

// Basic logging
Log::channel('supabase')->info('User logged in', ['user_id' => 123]);

// Error logging with context
Log::channel('supabase')->error('Payment failed', [
    'user_id' => 456,
    'order_id' => 789,
    'amount' => 99.99,
    'error' => $exception->getMessage()
]);

// Warning with tags
Log::channel('supabase')->warning('High memory usage detected', [
    'memory_usage' => '512MB',
    'tags' => ['performance', 'monitoring']
]);

return [
    // Supabase connection
    'supabase_url' => env('SUPABASE_URL'),
    'supabase_key' => env('SUPABASE_SERVICE_ROLE_KEY'),
    'table_name' => 'laravel_logs',

    // Performance settings
    'batch_size' => 50,
    'flush_interval' => 60, // seconds
    'timeout' => 30,
    'retry_attempts' => 3,
    'retry_delay' => 1000, // milliseconds

    // Auto-tagging
    'auto_tag_routes' => true,
    'auto_tag_users' => true,
    'auto_tag_ips' => true,
    'auto_tag_exceptions' => true,

    // Security
    'sanitize_sensitive_data' => true,
    'sensitive_keys' => ['password', 'token', 'secret', 'key'],

    // Fallback logging
    'fallback_to_file' => true,
    'fallback_path' => storage_path('logs/supabase-fallback.log'),
];

use Codexpedite\LaravelSupabaseLogger\Models\LaravelLog;

// Find logs by criteria
$criticalLogs = LaravelLog::level('error')
    ->forApp('my-app')
    ->forEnvironment('production')
    ->recent(24) // last 24 hours
    ->get();

// Update log status
$log = LaravelLog::find($id);
$log->acknowledge(); // Mark as acknowledged
$log->resolve();     // Mark as resolved
$log->reopen();      // Reopen (mark as new)
bash
php artisan vendor:publish --tag=supabase-logger-config
bash
php artisan supabase-logger:test
bash
php artisan supabase-logger:flush