cmdisp / monolog-microsoft-teams
Monolog Handler for sending messages to Microsoft Teams using the Incoming Webhook connector
Installs: 102 904
Dependents: 1
Suggesters: 1
Security: 0
Stars: 29
Watchers: 5
Forks: 8
Open Issues: 2
Requires
- php: ^7.2
- monolog/monolog: ^1.23|^2.0
Requires (Dev)
- ext-curl: *
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7|^6.0|^7.0
This package is not auto-updated.
Last update: 2021-01-18 13:45:34 UTC
README
Monolog Handler for sending messages to Microsoft Teams channels using the Incoming WebHook connector.
Install
$ composer require cmdisp/monolog-microsoft-teams
Usage
$logger = new \CMDISP\MonologMicrosoftTeams\TeamsLogger('INCOMING_WEBHOOK_URL', \Monolog\Logger::ERROR); $logger->error('Error message');
or
$logger = new \Monolog\Logger('app'); $logger->pushHandler(new \CMDISP\MonologMicrosoftTeams\TeamsLogHandler('INCOMING_WEBHOOK_URL', \Monolog\Logger::ERROR));
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.xml
and 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.