承接 rspeekenbrink/monolog-microsoft-teams 相关项目开发

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

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

rspeekenbrink/monolog-microsoft-teams

最新稳定版本:1.1.0

Composer 安装命令:

composer require rspeekenbrink/monolog-microsoft-teams

包简介

Monolog Handler for sending messages to Microsoft Teams using the Incoming Webhook connector

README 文档

README

Package Version Packagist Version

A Monolog handler to send Microsoft Teams messages via the Incoming Webhook.

Features

Send text messages to the incoming webhook of microsoft teams with different theme colors based on the log level. All this whilst using the well known monolog library as backbone!

Install

composer require rspeekenbrink/monolog-microsoft-teams

Usage

<?php

use Monolog\Logger;
use Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsHandler;

// create a log channel
$log = new Logger('microsoft-teams-logger');
$log->pushHandler(new MicrosoftTeamsHandler(
    'YOUR_WEBHOOK_URL',
    'Fancy Title',
    Logger::WARNING
));

// add records to the log
$log->warning('Foo');
$log->error('Bar');

or

<?php

use Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsLogger;

// create a log channel
$log = new MicrosoftTeamsLogger(
    'YOUR_WEBHOOK_URL',
    'Fancy Title',
    Logger::WARNING
);

// add records to the log
$log->warning('Foo');
$log->error('Bar');

Usage with Laravel/Lumen framework

From Laravel/Lumen 5.6+ you can easily use custom drivers for logging. First create a Custom Channel.

in config/logging.php add:

'teams' => [
    'driver' => 'custom',
    'via' => \Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsChannel::class,
    'level' => 'error',
    'url' => env('LOG_TEAMS_WEBHOOK_URL'),
    'title' => 'My Application'
],

then in your .env file add:

LOG_TEAMS_WEBHOOK_URL=YOUR_WEBHOOK_URL

Send error messages via the Log facade to the teams channel:

\Log::channel('teams')->error('Oh Snap, Stuff broke again!');

Or add the teams channel to the default stack channel in config/logging.php:

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

License

monolog-microsoft-teams is available under the MIT license. See the LICENSE file for more info.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-12