v-pack/laravel-gcloud-logging 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

v-pack/laravel-gcloud-logging

最新稳定版本:1.0.0

Composer 安装命令:

composer require v-pack/laravel-gcloud-logging

包简介

Google Cloud Logging package for Laravel

README 文档

README

Introduction

This package allows Laravel applications to log requests and responses to Google Cloud Logging. It includes a custom Monolog driver and a middleware to capture request logs, including cURL representations.

Installation

1. Install the Package

composer require username/laravel-gcloud-logging

2. Set Up Google Cloud Credentials

  1. Generate a Service Account Key in the Google Cloud Console.
  2. Download the JSON key file and place it in a secure directory in your Laravel project.
  3. Add the following environment variables in .env:
    GOOGLE_APPLICATION_CREDENTIALS=/path/to/google-service-account.json
    GOOGLE_CLOUD_PROJECT=your-project-id
    GOOGLE_CLOUD_LOG_NAME=your-log-name
    LOG_CHANNEL=google
    

Configuration

3. Publish the Config File (Optional)

If needed, publish the configuration file:

php artisan vendor:publish --tag=gcloud-logging-config

4. Custom Logging Driver

This package provides a custom logging driver. Ensure it is registered in config/logging.php:

'channels' => [
    'google' => [
        'driver' => 'custom',
        'via' => \VPACK\GCloudLogging\GoogleCloudLogger::class,
        'level' => 'debug',
    ],
],

Middleware for Logging Requests

5. Register Middleware

To log incoming requests and responses, add the middleware to app/Http/Kernel.php:

protected $middleware = [
    \VPACK\GCloudLogging\Middleware\LogCurlRequest::class,
];

Usage

6. Logging in Code

You can log manually using Laravel's Log facade:

use Illuminate\Support\Facades\Log;

Log::info('This is a test log', ['context' => 'example']);

7. View Logs in Google Cloud

  1. Open Google Cloud Logging.
  2. Filter logs by resource.type="global" or your custom log name.
  3. Monitor real-time logs.

Updating the Package

If new updates are available, update the package using:

composer update username/laravel-gcloud-logging

License

This package is open-source and licensed under the MIT License.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-16