Coder Social home page Coder Social logo

alexandresalvimoto / laravel-teams-logging Goto Github PK

View Code? Open in Web Editor NEW

This project forked from margatampu/laravel-teams-logging

0.0 0.0 0.0 445 KB

Laravel handler to sending messages to Microsoft Teams using the Incoming Webhook connector

License: MIT License

PHP 100.00%

laravel-teams-logging's Introduction

laravel-teams-logging

Latest Version on Packagist Software License Total Downloads

Laravel handler to sending messages to Microsoft Teams using the Incoming Webhook connector.

Installation

Require this package with composer.

$ composer require margatampu/laravel-teams-logging

Integration

Package tested and worked with Laravel and Lumen framework (5.7+).

Laravel: After installation using composer finishes up, you'll have to add the following line to your config/app.php:

MargaTampu\LaravelTeamsLogging\LoggerServiceProvider::class

Lumen: For Lumen, you'll have to add the following line to your bootstrap/app.php:

$app->register(MargaTampu\LaravelTeamsLogging\LoggerServiceProvider::class);

Laravel: Then copy teams config file from laravel-teams-logging to your config folder:

$ php artisan vendor:publish --provider="MargaTampu\LaravelTeamsLogging\LoggerServiceProvider"

Lumen: For Lumen, you need to copy file manually to your config folder and enable it in bootstrap/app.php:

$app->configure('teams');

Create a custom channel using laravel logging file or create new logging config file for lumen.

Add this configuration to config/logging.php file

'teams' => [
    'driver'    => 'custom',
    'via'       => \MargaTampu\LaravelTeamsLogging\LoggerChannel::class,
    'level'     => 'debug',
    'url'       => env('INCOMING_WEBHOOK_URL'),
    'style'     => 'simple',    // Available style is 'simple' and 'card', default is 'simple'
],

or simply add name to specify different project name for each connector.

'teams' => [
    'driver'    => 'custom',
    'via'       => \MargaTampu\LaravelTeamsLogging\LoggerChannel::class,
    'level'     => 'debug',
    'url'       => env('INCOMING_WEBHOOK_URL'),
    'style'     => 'simple',    // Available style is 'simple' and 'card', default is 'simple'
    'name'      => 'Dummy Project'
],

There are 2 available styles for microsoft teams message, using simple and card. You can see card style in results style which is difference from simple style.

After added configs to your config/logging.php file, add INCOMING_WEBHOOK_URL variable to your .env file with connector url from your microsoft teams connector. Please read microsoft teams document to find your connector url.

Usage

To send a simple error message to teams channel, you kindly use script below:

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

Or you can include additional info to card message using log context.

Log::channel('teams')->error('Error message', [
    [
        'name'  => 'Assigned to',
        'value' => 'Unassigned',
    ]
]);

When using simple style, log context will ignore from 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'],
    ],
],

Results

Here are some results of notifications sent to microsoft teams channel using card style.

  • Debug log preview in microsoft teams channel Screenshot

  • Info log preview in microsoft teams channel Screenshot

  • Notice log preview in microsoft teams channel Screenshot

  • Warning log preview in microsoft teams channel Screenshot

  • Error log preview in microsoft teams channel Screenshot

  • Critical log preview in microsoft teams channel Screenshot

  • Alert log preview in microsoft teams channel Screenshot

  • Emergency log preview in microsoft teams channel Screenshot

License

This laravel-teams-logging package is available under the MIT license. See the LICENSE file for more info.

laravel-teams-logging's People

Contributors

stampubolon avatar margatampu avatar j-dohnalek avatar lucky-loek avatar dgood-gdba avatar sh-ogawa avatar

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.