devorto/microsoft-teams-logger

Logs errors/notices etc to Microsoft Teams using Psr/LoggerInterface.

1.0.0 2020-05-18 11:04 UTC

This package is auto-updated.

Last update: 2024-04-19 15:37:47 UTC


README

Send errors/notices/warnings etc to Microsoft Teams, using this Class which implements the Prs/Log/LoggerInterface.

For more information about the logger interface or log levels see their github.

Setup webhook

Before you can use this you need to setup a webhook in a Microsoft Teams channel.

  1. Goto https://teams.microsoft.com/ and select a team.
  2. Right mouse click on the desired channel and click "Connectors".
  3. Search for "Incoming Webhook" and click "configure".
  4. Provide a name and image.
  5. Click on "Create".
  6. A new field will now appear with the new webhook url in it which you can copy-paste.

Example

<?php

$slack = new \Devorto\Logger\MicrosoftTeams(
	'<paste-webhook-url-here>',
	'My Test App',
	'https://test.example.com' // Optional app url.
);

// Use one of the available log level methods:
$slack->critical('Help something went critical.');

// You can also drop an Exception in here.
$slack->critical(new Exception('Test'));

Produces this in Microsoft Teams: Example