piwik/piwik — pull request #6842 by mnapoli (2014-12-11 01:53:16+00:00)
Title: Separated error and exception handling from logging

This is an implementation of the changes I suggested in #6813: **separating logging and exception handling**.

I'm opening it as a separate pull request so that we can discuss it here (wether we want this or not) and I can post screenshots without flooding the other pull request.

## Summary

- the logger doesn't log anything on "screen" (html)
- the error handler logs warnings and notices, and turns errors into exceptions (`ErrorException`)
- the exception handler catches all uncatched exceptions (including `ErrorException`) and **display them** to the user (HTML or CLI)
- the "screen" logging backend has been removed
- I've normalized exceptions/errors shown to the user in HTML (wether they are catched by the FrontController or not)

## Screenshots

### Uncatched exception in a controller/API/…

Same as before:

![capture d ecran 2014-12-11 a 14 42 04](https://cloud.githubusercontent.com/assets/720328/5387743/f529559a-8143-11e4-876d-d135b27c1e76.png)

### Uncatched exception outside of the dispatch loop

Before:

![capture d ecran 2014-12-11 a 14 46 20](https://cloud.githubusercontent.com/assets/720328/5387779/9c2daa9e-8144-11e4-891c-85b656dd3993.png)

Now:

![capture d ecran 2014-12-11 a 14 47 50](https://cloud.githubusercontent.com/assets/720328/5387799/b53c478e-8144-11e4-96ee-b2059f974e08.png)

### Error

Was:

![capture d ecran 2014-12-11 a 14 45 40](https://cloud.githubusercontent.com/assets/720328/5387765/69aad3e4-8144-11e4-989c-c0968ecafb86.png)

Now looks like this:

![capture d ecran 2014-12-11 a 14 43 38](https://cloud.githubusercontent.com/assets/720328/5387750/1e5ffa40-8144-11e4-8238-1ca4ac8fdccd.png)

### Fatal error

Same as before:

![capture d ecran 2014-12-11 a 14 44 37](https://cloud.githubusercontent.com/assets/720328/5387757/49d3caf8-8144-11e4-94e2-09e38df06f54.png)

### Custom message logged when `screen` logging is enabled

Example code:

```php
Log::warning('This is a warning');
Log::error('This is an error');
```

Before:

![capture d ecran 2014-12-11 a 14 51 26](https://cloud.githubusercontent.com/assets/720328/5387842/35c554a4-8145-11e4-893a-97187ae60969.png)

(the lines of log where added at the top of the page)

Now:

![capture d ecran 2014-12-11 a 14 50 35](https://cloud.githubusercontent.com/assets/720328/5387832/1787e196-8145-11e4-9b10-16ec1b374fc5.png)

(not displayed anymore)