Since the code does not need neither the 'object' not 'args' keys from backtrace, we can save some memory by not requesting them.
I have a better idea planned too: first attempt getting the trace with limited back trace (limit to only about 5 results), and get the full one only if those were not enough
According to slack documentation (https://api.slack.com/docs/attachments), an attachment may have a title and a text. The log message and title should use these fields. One of the benefits of using these two properties instead of adding a field is that it's shortened (with a "show more" button) and expandable by slack. It adds a bit of hierarchy in the attachement. Message is the content. Extra and context are additional fields.
Recent merge of #608 misses check whether the trace exists at all at the specific index, leading to undefined offset.
```
E_NOTICE: Undefined offset: 3
```
And because the while statement became unreadable (and too long), I moved it into a separate method.
Fixes bug with error handler. Once `curl_close($ch)` is called, then `curl_errno($ch)` and `curl_error($ch)` makes no sense and will cause an error in the exception handler.
Logger::setHandlers() is intended to help dependency injection systems
that deal more elegantly with property setters than constructor
arguments. Alongside getHandlers(), pushHandler(), popHandler(), it is
a logical addition to the API.
It also attempts to address some possible errors in the format of the
data passed:
- If a map is passed, the keys are removed, as these aren’t expected
by Monolog
- If falsey values are included, these are stripped
It relies on Logger::pushHandler() internally, so that if any special
behaviour is added in the future, this only needs to be added in one
place.