定制 ami-praha/ai-logger 二次开发

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

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

ami-praha/ai-logger

Composer 安装命令:

composer require ami-praha/ai-logger

包简介

A Laravel package that provides a logging driver to send logs to a specified external webhook.

README 文档

README

Repository

ami-praha/ai-logger
Description: A Laravel package providing a logging channel that sends log messages to an external webhook.

Overview

This package adds a custom Laravel logging channel called ai-logger. When used, it sends log messages (and context data) as JSON payloads to a configured webhook URL.

Installation

Require the package via Composer:

composer require ami-praha/ai-logger:"0.0.*"

No further configuration file publishing is necessary.

Configuration

Environment Variable

Set the webhook URL in your application's .env file:

AI_LOGGER_WEBHOOK_URL="http://ai-logger.test/api/receive"
AI_LOGGER_SOURCE_CODE="EXAMPLEAPP"
AI_LOGGER_SOURCE_NAME="Example App"
AI_LOGGER_SOURCE_URL="http://example-app.test"
AI_LOGGER_SOURCE_GIT_PROJECT_OWNER="EXP"
AI_LOGGER_SOURCE_GIT_PROJECT_NAME="example_app"
AI_LOGGER_SOURCE_JIRA_PROJECT_CODE="EXPAPP"
AI_LOGGER_SOURCE_JIRA_PARENT_PROJECT_KEY="EXPAPP-123"

Configuring Logging Channel

In Laravel's config/logging.php, add a new channel ai-logger. Also if you are using a stack channel and want to automatically send any logs to ai-logger (recommended), add it to stack.channels array:

// config/logging.php
return [
    'default' => env('LOG_CHANNEL', 'stack'),

    'channels' => [
        // other channels...

        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'slack', 'ai-logger'],
        ],

        'ai-logger' => [
            'driver' => 'ai-logger',
            'webhookUrl' => env('AI_LOGGER_WEBHOOK_URL'),
            'sourceCode' => env('AI_LOGGER_SOURCE_CODE'),
            'sourceName' => env('AI_LOGGER_SOURCE_NAME'),
            'sourceUrl' => env('AI_LOGGER_SOURCE_URL'),
            'sourceGitProjectOwner' => env('AI_LOGGER_SOURCE_GIT_PROJECT_OWNER'),
            'sourceGitProjectName' => env('AI_LOGGER_SOURCE_GIT_PROJECT_NAME'),
            'sourceJiraProjectCode' => env('AI_LOGGER_SOURCE_JIRA_PROJECT_CODE'),
            'sourceJiraParentProjectKey' => env('AI_LOGGER_SOURCE_JIRA_PARENT_PROJECT_KEY'),
            'level' => 'warning',
        ],
    ],
];

Usage

To log using AI Logger, specify the ai-logger channel in your code:

use Illuminate\Support\Facades\Log;

Log::channel('ai-logger')->info('Hello from AI Logger', ['extra_data' => 'test']);

// Other log levels work similarly
Log::channel('ai-logger')->error('Something went wrong.', [
    'exception' => 'Some exception info',
]);

This will send the log message, context data, log level, and timestamp as a JSON payload to the configured webhook URL.

Verifying Functionality

  1. Set up a Test Webhook: Use tools like Webhook.site or RequestBin to create a temporary webhook endpoint.

  2. Trigger a Log: Execute a log statement:

    Log::channel('ai-logger')->info('Testing AI Logger');
  3. Inspect Received Payload: Confirm the JSON payload arrives at your test webhook.

Requirements

  • PHP: ^7.4 | ^8.0 | ^8.1 | ^8.2 | ^8.3
  • Laravel: ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0

Contributing

Contributions are welcome!

  1. Fork and create a feature branch.
  2. Submit your changes through a Pull Request.
  3. Provide a clear description of your updates.

For bugs or feature requests, please create an issue on GitHub.

License

Licensed under the MIT License.

Thank you for using AI Logger! If you have questions, open an issue on GitHub or contact the maintainer.

ami-praha/ai-logger 适用场景与选型建议

ami-praha/ai-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.12k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 ami-praha/ai-logger 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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