{"id":15372635,"url":"https://github.com/gmponos/monolog-slack","last_synced_at":"2025-04-15T11:33:15.511Z","repository":{"id":55905280,"uuid":"126599564","full_name":"gmponos/monolog-slack","owner":"gmponos","description":"Monolog webhook handler for sending your logs to slack","archived":false,"fork":false,"pushed_at":"2020-12-08T07:48:51.000Z","size":157,"stargazers_count":10,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-01T10:42:08.384Z","etag":null,"topics":["log","logger","logging","monolog","monolog-handler","php","php7","slack","slack-webhook"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmponos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["gmponos"]}},"created_at":"2018-03-24T13:00:57.000Z","updated_at":"2022-02-12T07:32:23.000Z","dependencies_parsed_at":"2022-08-15T09:10:14.127Z","dependency_job_id":null,"html_url":"https://github.com/gmponos/monolog-slack","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmponos%2Fmonolog-slack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmponos%2Fmonolog-slack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmponos%2Fmonolog-slack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmponos%2Fmonolog-slack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmponos","download_url":"https://codeload.github.com/gmponos/monolog-slack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223673050,"owners_count":17183618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["log","logger","logging","monolog","monolog-handler","php","php7","slack","slack-webhook"],"created_at":"2024-10-01T13:52:32.627Z","updated_at":"2024-11-08T11:03:25.145Z","avatar_url":"https://github.com/gmponos.png","language":"PHP","funding_links":["https://github.com/sponsors/gmponos"],"categories":[],"sub_categories":[],"readme":"# Send logs to Slack using Monolog\n\n[![codecov](https://codecov.io/gh/gmponos/monolog-slack/branch/master/graph/badge.svg)](https://codecov.io/gh/gmponos/monolog-slack)\n[![Build Status](https://travis-ci.org/gmponos/monolog-slack.svg?branch=master)](https://travis-ci.org/gmponos/monolog-slack)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/2ba4ce7d-cdce-4424-ae6b-deae0107bace/mini.png)](https://insight.sensiolabs.com/projects/2ba4ce7d-cdce-4424-ae6b-deae0107bace)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gmponos/monolog-slack/blob/master/LICENSE.md)\n\n**Notice** I have created another package that contains a collection of Monolog handlers that can send your logs using a PSR-18 clients. The package is [monolog-http](https://github.com/monolog-http/monolog-http)\n\nI will focus my efforts on the package above. If you are using the current package let me know WDYT.\n\nGive a :star: to monolog-http if you like it.\n\n## Description\n\nThis is a package that can help you send logs through monolog to Slack using webhooks.\nMonolog already has a handler for Slack using Webhooks but I am not in favor of it for these reasons:\n\n**It has some bugs**\n\n- Slack accepts 2000 characters. For more details [see](https://github.com/Seldaek/monolog/issues/909). \nCurrent package is not able to send more than 2000 characters but it is able to send until 2000 characters \nand be well formatted.\n\n**Flexibility**\n\n- The Handler on this package allows you to pass your own PSR-18 client that can be configured in your own way.\n\n**Performance**\n\n- SlackWebhookHandler does not have timeouts and it executes retries when slack service is down [see](https://github.com/Seldaek/monolog/pull/846#issuecomment-373522968)\nBecause you are allowed to pass your own PSR-18 client you can have it configured in your own way.\n\n**Formatting**\n\n- Current package gives you the ability to add a custom formatter to the `SlackwebhookHandler` in order to format Attachments.\nMonolog allows you to  pass a formatter to SlackHandlers but the formatter is applied only to simple messages of slack\nand they are not applied for Attachments.\n- I have created my own custom formatters. I like the formatting of Slack Records that I have more than the one that monolog has.\n \n## Install\n\nYou can install this package through composer\n\n```\n$ composer require webthink/monolog-slack\n```\n\n## Documentation\n\n### Simple initialization\nYou can initialize a `SlackWebhookHandler` simple with the following lines:\n\n```php\n$client = new PSR18Client(); // PSR18Client does not exist. Use your own implementation.\n$requestFactory = new PSR17RequestFactory(); // PSR18Client does not exist. Use your own implementation.\n$handler = new SlackWebhookHandler($client, $requestFactory, 'your_webhook_url');\n```\n\n## Formatters\n\n### Inject custom formatter\n\nNow if you need to pass a custom slack formatter then you can to do the following:\n\n`$handler-\u003esetFormatter($yourFormatter);`\n\n- **Note-1:** The formatter passed inside the slack handler must be an instance of `SlackFormatterInterface`.\n- **Note-2:** If you do not pass a custom Formatter SlackWebhookHandler uses the `SlackLineFormatter` by default.\n\n### SlackLineFormatter\n\n![slacklineformatter](docs/slacklineformatter.PNG)\n\n### SlackShortAttachmentFormatter\n\n![slackshortattachementformatter](docs/slackshortattachementformatter.PNG)\n\n### SlackLongAttachmentFormatter\n\n![slacklongattachementformatter](docs/slacklongattachementformatter.PNG)\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n1. Run `composer install` from bash.\n2. Run `composer tests` from bash.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmponos%2Fmonolog-slack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmponos%2Fmonolog-slack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmponos%2Fmonolog-slack/lists"}