PHP code example of mepsd / laravel-google-chat-logger
1. Go to this page and download the library: Download mepsd/laravel-google-chat-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/ */
mepsd / laravel-google-chat-logger example snippets
'channels' => [
'google_chat' => [
'driver' => 'custom',
'via' => Mepsd\LaravelGoogleChatLogger\GoogleChatLogger::class,
'url' => env('GOOGLE_CHAT_WEBHOOK_URL'),
'level' => env('LOG_LEVEL', 'debug'),
'retries' => 2, // Number of retry attempts
'timeout' => 5, // Request timeout in seconds
],
],
// Simple info message
Log::info('User registered successfully', ['user_id' => 1]);
// Error with exception
try {
// Some code
} catch (Exception $e) {
Log::error('Process failed', [
'exception' => $e,
'user_id' => 1
]);
}
// Order Processing Thread
$threadKey = 'order-' . $orderId;
Log::info('Order received', [
'thread_key' => $threadKey,
'order_id' => $orderId,
'amount' => 99.99
]);
Log::info('Processing payment', [
'thread_key' => $threadKey,
'payment_method' => 'credit_card'
]);
Log::info('Order completed', [
'thread_key' => $threadKey,
'status' => 'completed'
]);
// User Activity Thread
$userThread = 'user-' . $userId;
Log::info('User logged in', [
'thread_key' => $userThread,
'ip' => $request->ip()
]);
Log::warning('Failed login attempt', [
'thread_key' => $userThread,
'attempts' => 3
]);
try {
// Your code
} catch (Exception $e) {
Log::error('Process failed', [
'thread_key' => 'process-123',
'exception' => $e,
'additional_data' => $data
]);
}
'google_chat' => [
'driver' => 'custom',
'via' => Mepsd\LaravelGoogleChatLogger\GoogleChatLogger::class,
'url' => env('GOOGLE_CHAT_WEBHOOK_URL'),
'level' => env('LOG_LEVEL', 'debug'),
'retries' => 2, // Number of retry attempts
'timeout' => 5, // Request timeout in seconds
],
'user-{id}' // For user activities
'order-{id}' // For order processing
'deploy-{date}' // For deployments
'job-{id}' // For background jobs
$threadKey = 'payment-' . $paymentId;
Log::info('Starting payment', ['thread_key' => $threadKey]);
Log::info('Processing', ['thread_key' => $threadKey]);
Log::info('Completed', ['thread_key' => $threadKey]);
Log::info('User action', [
'thread_key' => 'user-123',
'action' => 'profile_update',
'changes' => ['name' => 'New Name'],
'ip' => $request->ip()
]);