PHP code example of dmitrijkalugin / message-log
1. Go to this page and download the library: Download dmitrijkalugin/message-log 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/ */
dmitrijkalugin / message-log example snippets
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'messagelog'],
'ignore_exceptions' => false,
],
'messagelog' => [
'driver' => 'monolog',
'handler' => \MessageLog\MessageLogHandler::class,
'level' => env('LOG_LEVEL', 'error'),
],
// ... другие каналы
],
'channels' => [
'telegram' => [
'enabled' => true,
'levels' => ['emergency', 'alert', 'critical', 'error'],
],
],
// Эти логи автоматически отправятся в настроенные мессенджеры
Log::error('Произошла ошибка', ['user_id' => 123]);
Log::critical('Критическая ошибка системы!');
Log::emergency('Система недоступна!');
// С контекстом
Log::error('Ошибка оплаты', [
'order_id' => 12345,
'amount' => 1000,
'error' => 'Payment gateway timeout'
]);
namespace MessageLog\Handlers;
class CustomHandler extends AbstractHandler
{
public function send(string $level, string $message, array $context = []): bool
{
// Ваша реализация
}
}
bash
php artisan vendor:publish --tag=messagelog-config
bash
php artisan queue:work