定制 techfy/got-your-logs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

techfy/got-your-logs

Composer 安装命令:

composer require techfy/got-your-logs

包简介

A Laravel package for logging actions to daily JSON files.

README 文档

README

Got Your Logs is a Laravel package that allows you to log every action in your Laravel project. Logs are stored in daily JSON files, and the log format is customizable to fit your needs. This package is designed to be easy to use and integrate into any Laravel application.

Features

  • Automatic Logging: Log any action or event in your Laravel application with a simple method call.
  • Daily JSON Files: Logs are stored in daily JSON files, making it easy to manage and review.
  • Customizable Format: Modify the log format to include the information you need.
  • Simple Integration: Easy to install and use in any Laravel project.

Installation

To install the techfy/got-your-logs package, follow these steps:

Step 1: Require the Package

You can install it using Composer:

composer require techfy/got-your-logs

Step 2: Register the Service Provider and Facade

After installation, register the service provider and facade in your config/app.php file:

'providers' => [
    // Other Service Providers
    Techfy\GotYourLogs\GotYourLogsServiceProvider::class,
],

'aliases' => [
    // Other Aliases
    'GotYourLogs' => Techfy\GotYourLogs\LogFacade::class,
],

Step 3: Publish the Configuration File

To customize the log format and storage location, you can publish the configuration file:

php artisan vendor:publish --tag=config --provider="Techfy\GotYourLogs\GotYourLogsServiceProvider"

This will create a config/gotyourlogs.php file in your Laravel project.

Usage

Logging an Action

You can log any action or event in your Laravel application using the GotYourLogs facade. Here's an example of how to log a user login action:

use GotYourLogs;

GotYourLogs::log('UserLogin', [
    'user_id' => auth()->user()->id,
    'status' => 'success',
    'ip_address' => request()->ip(),
]);

Log File Structure

Logs are stored in JSON files named after the current date (e.g., 2024-08-21.json). Each log entry includes the time, operation name, and details of the action. An example log entry might look like this:

{
    "time": "2024-08-21 09:15:32",
    "operation": "UserLogin",
    "details": {
        "user_id": 101,
        "status": "success",
        "ip_address": "192.168.1.10"
    }
}

Customizing the Log Format

You can customize the log format by editing the config/gotyourlogs.php file. The default configuration looks like this:

return [
    'log_format' => [
        'time' => 'Y-m-d H:i:s',
        'operation' => '',
        'details' => '',
    ],
    'storage_path' => storage_path('logs/got-your-logs'),
];
  • time: The format for the timestamp in the logs. You can modify this to match your preferred date/time format.
  • operation: The name of the action or event being logged.
  • details: Additional details about the action.

Modifying the Storage Path

By default, logs are stored in the storage/logs/got-your-logs/ directory. You can change the storage path by modifying the storage_path key in the config/gotyourlogs.php file:

'storage_path' => storage_path('custom-logs-directory'),

Contributing

Contributions are welcome! If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.

License

Got Your Logs is open-sourced software licensed under the MIT license.

techfy/got-your-logs 适用场景与选型建议

techfy/got-your-logs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 techfy/got-your-logs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 techfy/got-your-logs 我们能提供哪些服务?
定制开发 / 二次开发

基于 techfy/got-your-logs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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