承接 veho-dev/s3-logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

veho-dev/s3-logger

Composer 安装命令:

composer require veho-dev/s3-logger

包简介

A Laravel package to log messages to AWS S3

README 文档

README

Introduction

The S3 Logger package provides a simple way to log messages to AWS S3 with project separation and automatic local log cleanup in Laravel. This package allows you to send logs from multiple Laravel projects to a specified S3 bucket, with each project's logs stored in separate folders. Additionally, logs are automatically deleted from the local storage after one week.

Installation

Step 1: Install via Composer

You can install the package via Composer. If you have registered the package on Packagist, run the following command:

composer require veho-dev/s3-logger

Step 2: Publish the Configuration (Optional)

If you want to customize the configuration, you can publish the package configuration file using the command:

php artisan vendor:publish --provider="VehoDev\S3Logger\Providers\S3LoggerServiceProvider"

Step 3: Add Environment Variables

Add the following environment variables to your .env file:

LOG3_AWS_ACCESS_KEY_ID=your_access_key
LOG3_AWS_SECRET_ACCESS_KEY=your_secret_key
LOG3_AWS_DEFAULT_REGION=your_region
LOG3_AWS_S3_BUCKET=your_bucket_name
APP_NAME=your_project_name
LOG3_AWS_Role_Arn=your_role_key
LOG3_AWS_Role_Session_Name=your_role_session_name
LOG3_ASSUME_ROLE=have_assume_role_yes_or_not

  • LOG3_AWS_ACCESS_KEY_ID: Your AWS access key.
  • LOG3_AWS_SECRET_ACCESS_KEY: Your AWS secret key.
  • LOG3_AWS_DEFAULT_REGION: The AWS region where your S3 bucket is located.
  • LOG3_AWS_S3_BUCKET: The name of your S3 bucket.
  • APP_NAME: The name of your project (used for folder separation in S3).
  • LOG3_AWS_Role_Arn: Your AWS IAM Role key
  • LOG3_AWS_Role_Session_Name: Your AWS IAM Role session name
  • LOG3_ASSUME_ROLE: True if this project have AWS_Role_Arn or AWS_Role_Session_Name

Usage

To log requests to AWS S3 in a Laravel 10 application, add the logs3.crud middleware to your routes. For example:

use Illuminate\Support\Facades\Route;

Route::middleware(['logs3.crud'])->group(function () {
    Route::get('/example', function () {
        return 'This route logs to S3!';
    });
});

This will automatically log the message to a file stored in your S3 bucket under the folder named after your project. The logs will be organized by date, with each day's logs stored in a separate file.

Local Log Cleanup

The package also provides automatic cleanup of local logs. Logs stored locally in your project will be deleted one week after they are created, reducing the storage burden on your local system.

View all file log

  • You can access the route /s3-logger/logs to see the log files on your s3.
  • Note if you have multiple projects that share the same s3 you can add the attribute /s3-logger/logs?show=all to see the logs of all projects

Contributing

If you find a bug or have a feature request, feel free to create an issue or submit a pull request. Contributions are always welcome!

###License

This package is open-source software licensed under the VehoWork license.

### Additional Notes
- Replace `https://github.com/tuancuongth88/s3-logger.git` with the actual URL of your GitHub repository.
- Ensure that all placeholders like `your_access_key`, `your_secret_key`, etc., are replaced with actual values in the `.env` file when configuring your projects.
- If you publish the package on Packagist, make sure to update the badges and links accordingly.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-29