cbytedigital/laravel-teams-logger

Laravel package to log exceptions to a Microsoft Teams channel using Microsoft Teams Webhooks.

v2.0.0 2024-04-02 11:47 UTC

This package is auto-updated.

Last update: 2024-05-02 12:03:45 UTC


README

PHP from Packagist Latest Version on Packagist Software License Total Downloads

A Laravel package which can be used for log handling through laravel logging using the Microsoft teams webhook.

Installation

Use composer to install this package:

$ composer require cbytedigital/laravel-teams-logger

Usage

After installing the package through composer, we need to edit the logging. We have to add a teams channel with the following information. (The channel name can be whatever you want, just match it with the channel entered in the array of the stack channel)

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'teams' /** This is important for the channel to register properly */],
        'ignore_exceptions' => false,
    ],
    
    ...
    
    'teams' => [
        'driver' => 'custom',
        'via' => \CbyteDigital\TeamsLogger\Logging\TeamsLoggingChannel::class,
        'type' => \CbyteDigital\TeamsLogger\Enums\LogType::EXCEPTION,
        'level' => 'error',
        'url' => env('TEAMS_WEBHOOK_URL') /** This is the webhook URL generated by Teams */,
        'name' => 'Project name',
    ],
]

How to get a Webhook URL in Microsoft Teams

Create a channel inside Microsoft Teams and open the channel. In the top right corner of the channel, you will see three dots. If you click there, you will have to go to Connectors.

Here you will install the connector 'Incoming Webhook'. Next you can configure this for each project. Enter a name and icon and click on 'create'. This will generate a URL which we need for this package to work.

Testing

Run the tests with:

$ composer test

Support

Version Laravel Version PHP Version
1.x >= 8.x >=8.0

Postcardware

This package is completely free to use. If it makes it to your production environment we would highly appreciate you sending us a postcard from your hometown! 👏🏼

Our address is: CBYTE Software B.V., Heuvelkamp 2a, 6658DE Beneden-Leeuwen, Netherlands.

License

The MIT License (MIT). Please see License File for more information.