| 1 |
<?php |
| 2 |
|
| 3 |
class Raven_Breadcrumbs_ErrorHandler |
| 4 |
{ |
| 5 |
protected $existingHandler; |
| 6 |
|
| 7 |
/** |
| 8 |
* @var Raven_Client the client object that sends the message to the server |
| 9 |
*/ |
| 10 |
protected $ravenClient; |
| 11 |
|
| 12 |
/** |
| 13 |
* @param Raven_Client $ravenClient |
| 14 |
*/ |
| 15 |
public function __construct(Raven_Client $ravenClient) |
| 16 |
{ |
| 17 |
$this->ravenClient = $ravenClient; |
| 18 |
} |
| 19 |
|
| 20 |
public function handleError($code, $message, $file = '', $line = 0, $context = array()) |
| 21 |
{ |
| 22 |
$this->ravenClient->breadcrumbs->record(array( |
| 23 |
'category' => 'error_reporting', |
| 24 |
'message' => $message, |
| 25 |
'level' => $this->ravenClient->translateSeverity($code), |
| 26 |
'data' => array( |
| 27 |
'code' => $code, |
| 28 |
'line' => $line, |
| 29 |
'file' => $file, |
| 30 |
), |
| 31 |
)); |
| 32 |
|
| 33 |
if ($this->existingHandler !== null) { |
| 34 |
return call_user_func($this->existingHandler, $code, $message, $file, $line, $context); |
| 35 |
} else { |
| 36 |
return false; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
public function install() |
| 41 |
{ |
| 42 |
$this->existingHandler = set_error_handler(array($this, 'handleError'), E_ALL); |
| 43 |
return $this; |
| 44 |
} |
| 45 |
} |
| 46 |
|