pagevamp/laravel-stack-driver-logger
Composer 安装命令:
composer require pagevamp/laravel-stack-driver-logger
包简介
README 文档
README
Google Cloud Stack Driver error monitoring integration for Laravel projects. This library adds a listener to Laravel's logging component. Laravel's session information will be sent in to Stack Driver, as well as some other helpful information such as 'environment', 'server', and 'session'.
Installation
Install using composer:
composer require pagevamp/laravel-stack-driver-logger
Add the service provider to the 'providers' array in config/app.php:
Pagevamp\Providers\StackDriverLoggerServiceProvider::class,
If you only want to enable Stack Driver reporting for certain environments you can conditionally load the service provider in your AppServiceProvider:
public function register() { if ($this->app->environment('production')) { $this->app->register(\Pagevamp\Providers\StackDriverLoggerServiceProvider::class); } }
Configuration
This package supports configuration through the services configuration file located in config/services.php. All configuration variables will be directly passed to Stack Driver:
'stack_driver_logger' => [ 'credentials' => [ 'keyFile' => json_decode(trim(env('GC_LOG_SERVICE_CRED'), "'"), 1), ], 'log_name' => env('GC_LOG_NAME', 'builder-log'), ],
Usage
To automatically monitor exceptions, simply use the Log facade in your error handler in app/Exceptions/Handler.php:
public function report(Exception $exception) { \Log::error($exception); //Stack Driver parent::report($exception); }
Your other log messages will also be sent to Stack Driver:
\Log::debug('Here is some debug information');
NOTE: Fatal exceptions will always be sent to Stack Driver.
Context informaton
You can pass user information as context like this:
\Log::error('Something went wrong', [ 'person' => ['id' => 123, 'username' => 'John Doe', 'email' => 'john@doe.com'] ]);
Or pass some extra information:
\Log::warning('Something went wrong', [ 'download_size' => 3432425235 ]);
统计信息
- 总下载量: 8.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-26