承接 theriddleofenigma/laravel-google-chat-log 相关项目开发

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

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

theriddleofenigma/laravel-google-chat-log

Composer 安装命令:

composer require theriddleofenigma/laravel-google-chat-log

包简介

Brings up the option for sending the logs to google chat [Google Workplace formerly called GSuite].

README 文档

README

♥ Made with <love/> And I love <code/>

Laravel Google Chat Log

Brings up the option for sending the logs to google chat [Google Workspace formerly called GSuite] from Laravel/Lumen.

Installation

Composer install

composer require theriddleofenigma/laravel-google-chat-log

For laravel 9.x or lower, please use v1.x

composer require theriddleofenigma/laravel-google-chat-log:^1.3

Add the following code to the channels array in config/logging.php in your laravel/lumen application.

'google-chat' => [
    'driver' => 'monolog',
    'url' => env('LOG_GOOGLE_CHAT_WEBHOOK_URL'),
    'notify_users' => [
        'default' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT'),
        'emergency' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_EMERGENCY'),
        'alert' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_ALERT'),
        'critical' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_CRITICAL'),
        'error' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_ERROR'),
        'warning' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_WARNING'),
        'notice' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_NOTICE'),
        'info' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_INFO'),
        'debug' => env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEBUG'),
    ],
    'level' => env('LOG_LEVEL', 'debug'),
    'handler' => \Enigma\GoogleChatHandler::class,
],

You can provide the eight logging levels defined in the RFC 5424 specification: emergency, alert, critical, error, warning, notice, info, and debug

Note*: Make sure to set the LOG_GOOGLE_CHAT_WEBHOOK_URL env variable. And all other LOG_GOOGLE_CHAT_NOTIFY_USER_ID are optional. Here, you can set multiple google chat webhook url as comma separated value for the LOG_GOOGLE_CHAT_WEBHOOK_URL env variable.

Note*: For lumen, make sure the $app->withFacades(); is uncommented in the bootstrap/app.php.

Now, you can notify a specific user with @mention in the error log by setting the corresponding USER_ID to the LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT env variable. User Ids mapped under LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT will be notified for all log levels.

For getting the USER_ID, right-click the user-icon of the person whom you want to notify in the Google chat from your browser window and select inspect. Under the div element find the attribute data_member_id, then the USER_ID can be found as data-member-id="user/human/{USER_ID}>".

In order to notify all the users like @all, Set LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT=all. Also, you can set multiple USER_IDs as comma separated value. In order to notify different users for different log levels, you can set the corresponding env keys mentioned to configure in the logging.php file.

Now, you can add custom additional logs to the Google chat message by passing a closure function to the GoogleChatHandler::$additionalLogs property.

use Enigma\GoogleChatHandler;
use Illuminate\Http\Request;

class AppServiceProvider {
    public function register() {}
    public function boot() {
        GoogleChatHandler::$additionalLogs = function () {
            return [
                'tenant' => request()->user()?->tenant->name,
                'request' => json_encode(request()->toArray()),
            ];
        };
    }
}

License

Copyright © Kumaravel

Laravel Google Chat Log is open-sourced software licensed under the MIT license.

theriddleofenigma/laravel-google-chat-log 适用场景与选型建议

theriddleofenigma/laravel-google-chat-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68.76k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2021 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 theriddleofenigma/laravel-google-chat-log 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 24
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-21