Mattermost is an open-source platform for communication and collaboration with integrations with many tools. It is mostly considered as an open-source alternative to Slack and Microsoft Teams.
$ composer require muhamadhhassan/laramost
config/logging.php file, add the
mattermost channel to the
use LaraMost\Formatter\MattermostFormatter; use LaraMost\Handler\MattermostWebhookHandler; 'channels' => [ 'mattermost' => [ 'driver' => 'monolog', 'handler' => MattermostWebhookHandler::class, 'formatter' => MattermostFormatter::class, 'with' => [ 'hook' => 'https://your-mattermost.com/hooks/random-string', ], 'level' => 'error' ], ],
You can follow the steps here to create an incoming webhook for your channel.
Monolog levels are used to set the message color and icon
|Level Name||Level Value||Color||Emoji|
Simply, using Laravel
Log::channel('mattermost')->error('Something went wrong', ['user_id' => 5]);
Will send the following message to your mattermost channel:
⚠ Warning: When you log to the
mattermostchannel make sure that the level is greater than or equals the one defined in
And there you have it! A simple implementation to send log records to a Mattermost channel.