PHP code example of marekmiklusek / telegram-logger

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

    

marekmiklusek / telegram-logger example snippets


return [
    'bot_token' => env('TELEGRAM_BOT_TOKEN'),
    'chat_id' => env('TELEGRAM_CHAT_ID'),
    'level' => 'error',
    'silent_notification' => false,
    'is_enabled' => true,
];

use Illuminate\Support\Facades\Log;

Log::debug('Debug message');
Log::info('Info message');
Log::warning('Warning message');
Log::error('Error message');

Log::error('User not found', ['user_id' => 42, 'action' => 'login']);

try {
    throw new \Exception('Database connection failed!');
} catch (\Exception $exception) {
    Log::error('Unhandled exception occurred', ['exception' => $exception]);
}

return [
    'is_enabled' => false,
];

return [
    'level' => 'warning',
];

return [
    'silent_notification' => true,
];
bash
php artisan vendor:publish --tag=telegram-logger-config

🛠️ Application: MyLaravelApp
🌍 Environment: production

❌ Level: ERROR
🔥 Exception Occurred !
💥 Message: "Database connection failed!"

📌 File:
/var/www/html/app/Services/DatabaseService.php:30

⏳ Time: 2025-02-19 10:18:45
bash
php artisan config:clear
php artisan config:cache