Code Monkey home page Code Monkey logo

monolog-microsoft-teams's Introduction

monolog-microsoft-teams

Monolog Handler for sending messages to Microsoft Teams channels using the Incoming WebHook connector.

Install

$ composer require cmdisp/monolog-microsoft-teams

Usage

$logger = new \Monolog\Logger('app');
$logger->pushHandler(new \CMDISP\MonologMicrosoftTeams\TeamsLogHandler('INCOMING_WEBHOOK_URL', \Monolog\Level::Error));

$logger->error('Error message');

Usage with Laravel/Lumen framework (5.6+)

Create a custom channel

config/logging.php

'teams' => [
    'driver' => 'custom',
    'via' => \CMDISP\MonologMicrosoftTeams\TeamsLogChannel::class,
    'level' => 'error',
    'url' => 'INCOMING_WEBHOOK_URL',
],

Send an error message to the teams channel:

Log::channel('teams')->error('Error message');

You can also add teams to the default stack channel so all errors are automatically send to the teams channel.

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

Unit testing · PhpUnit

The tests require a valid Teams Incoming Webhook URL. To provide this URL to PhpUnit, copy phpunit.xml.dist to phpunit.xmland set the URL in the <php> section. Make sure to not commit your local phpunit.xml into the repo!

<php>
    <env name="TEAMS_INCOMING_WEBHOOK_URL" value="https://outlook.office.com/webhook/..." />
</php>

Run the tests on the command line:

$ composer test

License

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.