定制 muhamadhhassan/laramost 二次开发

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

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

muhamadhhassan/laramost

最新稳定版本:v1.1.0

Composer 安装命令:

composer require muhamadhhassan/laramost

包简介

This package includes a Monolog handler and formatter for Mattermost to use in a Laravel log channel

README 文档

README

Laramost is a Monolog handler channel for Laravel that allows you to send log records to a mattermost channel.

Installation

$ composer require muhamadhhassan/laramost

Levels

Monolog levels are used to set the message color and icon

Level Name Level Value Color Emoji
DEBUG 100 #91C4EB 🔍
INFO 200 #91C4EB ℹ️
NOTICE 250 #99cc33 📝
WARNING 300 #ffcc00 ⚠️
ERROR 400 #cc3300 🐛
CRITICAL 500 #cc3300
EMERGENCY 600 #cc3300 🚨

Usage

In Laravel Apps

In your config/logging.php add the mattermost channel to the channels array:

use LaraMost\Formatter\MattermostFormatter;
use LaraMost\Handler\MattermostWebhookHandler;

'channels' => [
    'mattermost' => [
        'driver'  => 'monolog',
        'handler' => MattermostWebhookHandler::class,
        'formatter' => MattermostFormatter::class,
        'with' => [
            'hook' => 'https://your-mattermost.com/hooks/xxx-generatedkey-xxx',
        ],
        'level' => 'error'
    ],
],

Then simply, using Laravel Log facade:

Log::channel('mattermost')->error('Something went wrong', ['user_id' => 5]);

In any PHP Apps

use Monolog\Logger;
use LaraMost\Formatter\MattermostFormatter;
use LaraMost\Handler\MattermostWebhookHandler;

$logger = new Logger('application');
$handler = new MattermostWebhookHandler('https://your-mattermost.com/hooks/xxx-generatedkey-xxx', Logger::ERROR);
$handler->setFormatter(new MattermostFormatter())
$logger->pushHandler($handler);

$logger->error('Something went wrong', ['user_id' => 5]);

Both Will send the following message to your mattermost channel: error-message.png

Warning: When you log to the mattermost channel make sure that the level is greater than or equals the one defined in config/logging.php

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-23