定制 jack-cc-kasa/laravel-mattermost-logging-driver 二次开发

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

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

jack-cc-kasa/laravel-mattermost-logging-driver

最新稳定版本:1.0.0

Composer 安装命令:

composer require jack-cc-kasa/laravel-mattermost-logging-driver

包简介

A log driver for Mattermost

README 文档

README

This driver allows you to send your logs to your Mattermost instance. It will attach exception stack traces and the log context/

Installation

composer require jack-cc-kasa/laravel-mattermost-logging-driver

Configuration

Add the new driver in your config/logging.php:

'mattermost' => [
    'driver' => 'custom',
    'via' => colbygarland\Mattermost\Logger\Factory::class,
    'webhook' => env('MATTERMOST_WEBHOOK'),
],

You can also add the mattermost channel to your stack driver if you wish:

'stack' => [
    'driver' => 'stack',
    'channels' => ['single', 'mattermost'],
],

Don't forget to set LOG_CHANNEL=single in your local and testing environments if you don't want to send logs to Mattermost during your tests.

Options

You can add additional options after the driver and via keys in your config/logging.php.

Option Default Description
webhook Your Mattermost webhook url. You must set this.
channel town-square The channel slug where the logs will be send.
level Logger::INFO Messages below this log level will not be sent.
level_mention Logger::ERROR Messages at or above this level will ping the usernames in the mentions key
title_format '**[%s]** %s' The message title format, expressed at a sprintf() formatted string
title_mention_format ' (ping %s)' The message title mention format, expressed at a sprintf() formatted string
username Laravel Log The username to display
mentions ['@channel'] An array of usernames to ping
short_field_length 62 Context content longer than this value will be formatted with a long field
max_attachment_length 6000 Content past this length will be truncated to avoid Mattermost refusing the payload.
icon_url null A relative icon URL to display. UrlGenerator is called to get the full path, so you can use this in multiple environments without resetting the key.
scribe null If you want to override the default message builder, provide your own fully qualified Scribe interface implementation
message null If you want to override the default message, provide your own fully qualified Message interface implementation

Usage

Use this driver like any other. You can send directly to the mattermost channel by using the Log facade, calling the logger function, or getting LogManager from the container. Then call channel(...) or stack([...]).

resolve(LogManager::class)
    ->channel('mattermost') // or ->stack(['single', 'bugsnag', 'mattermost'])
    ->info('Everyone loves a good log message.');

Sundries

Contributions welcomed.

MIT Licensed. Do as you wish.

Based on https://gitlab.com/thibauddauce/laravel-mattermost-logger/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-27