mirror of
https://github.com/Seldaek/monolog.git
synced 2025-02-24 15:02:28 +01:00
Inject rollbar handler.
Typecheck exceptions. Coding standard fix.
This commit is contained in:
parent
6734a4fbd1
commit
776a894487
@ -3,6 +3,7 @@
|
|||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use RollbarNotifier;
|
use RollbarNotifier;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends errors to Rollbar
|
* Sends errors to Rollbar
|
||||||
@ -19,26 +20,20 @@ class RollbarHandler extends AbstractProcessingHandler
|
|||||||
protected $rollbarNotifier;
|
protected $rollbarNotifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $token post_server_item access token for the Rollbar project
|
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
|
||||||
* @param string $environment This can be set to any string
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param string $root Directory your code is in; used for linking stack traces
|
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
|
||||||
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
|
||||||
*/
|
*/
|
||||||
public function __construct($token, $environment = 'production', $root = null, $level = Logger::ERROR, $bubble = true)
|
public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
|
||||||
{
|
{
|
||||||
$this->rollbarNotifier = new RollbarNotifier(array(
|
$this->rollbarNotifier = $rollbarNotifier;
|
||||||
'access_token' => $token,
|
|
||||||
'environment' => $environment,
|
|
||||||
'root' => $root,
|
|
||||||
));
|
|
||||||
|
|
||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function write(array $record)
|
protected function write(array $record)
|
||||||
{
|
{
|
||||||
if (isset($record['context']) and isset($record['context']['exception'])) {
|
if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
|
||||||
$this->rollbarNotifier->report_exception($record['context']['exception']);
|
$this->rollbarNotifier->report_exception($record['context']['exception']);
|
||||||
} else {
|
} else {
|
||||||
$this->rollbarNotifier->report_message(
|
$this->rollbarNotifier->report_message(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user