nmc / laravel-cloud-logging
Google Cloud Logging For Laravel
Installs: 2 548
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1|^8.2|^8.3
- google/cloud-error-reporting: ^0.22.1
- google/cloud-logging: ^1.25.2
- illuminate/contracts: ^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.14.1
README
Installation
You can install the package via composer:
composer require nmc/laravel-cloud-logging
You can publish the config file with:
php artisan vendor:publish --provider="Nmc\CloudLogging\CloudLoggingServiceProvider" --tag="cloud-logging-config"
This is the contents of the published config file:
return [ 'enable_error_reporting' => env('CLOUD_LOGGING_ENABLE_ERROR_REPORTING', isset($_SERVER['GAE_SERVICE']) ?? false), 'logger' => [ 'driver' => 'stackdriver', 'level' => env('LOG_LEVEL', 'debug'), 'name' => env('CLOUD_LOGGING_NAME', 'laravel-cloud-logging'), 'project' => env('CLOUD_LOGGING_PROJECT_ID'), 'credentials' => env('CLOUD_LOGGING_CREDENTIALS', config_path('stackdriver.json')), ], ];
Edit app/Exceptions/Handler.php
use Nmc\CloudLogging\CloudErrorReporting; public function register(): void { $this->reportable(function (Throwable $e) { if (CloudErrorReporting::isEnabled()) { CloudErrorReporting::report($e); } }); }
Usage
use Illuminate\Support\Facades\Log; Log::channel('stackdriver')->info('Test');
License
The MIT License (MIT). Please see License File for more information.