ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Monolog\Handler\RollbarHandler Class Reference

Sends errors to Rollbar. More...

+ Inheritance diagram for Monolog\Handler\RollbarHandler:
+ Collaboration diagram for Monolog\Handler\RollbarHandler:

Public Member Functions

 __construct (RollbarNotifier $rollbarNotifier, $level=Logger::ERROR, $bubble=true)
 
 close ()
 {Closes the handler.This will be called automatically when the object is destroyed} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
Boolean true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractHandler
 __construct ($level=Logger::DEBUG, $bubble=true)
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
Boolean
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 close ()
 Closes the handler. More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 setLevel ($level)
 Sets minimum logging level at which this handler will be triggered. More...
 
 getLevel ()
 Gets minimum logging level at which this handler will be triggered. More...
 
 setBubble ($bubble)
 Sets the bubbling behavior. More...
 
 getBubble ()
 Gets the bubbling behavior. More...
 
 __destruct ()
 
 isHandling (array $record)
 Checks whether the given record will be handled by this handler. More...
 
 handle (array $record)
 Handles a record. More...
 
 handleBatch (array $records)
 Handles a set of records at once. More...
 
 pushProcessor ($callback)
 Adds a processor in the stack. More...
 
 popProcessor ()
 Removes the processor on top of the stack and returns it. More...
 
 setFormatter (FormatterInterface $formatter)
 Sets the formatter. More...
 
 getFormatter ()
 Gets the formatter. More...
 

Protected Member Functions

 write (array $record)
 {Writes the record down to the log of the implementing handler.
Parameters
array$record
Returns
void
} More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 write (array $record)
 Writes the record down to the log of the implementing handler. More...
 
 processRecord (array $record)
 Processes a record. More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractHandler
 getDefaultFormatter ()
 Gets the default formatter. More...
 

Protected Attributes

 $rollbarNotifier
 
- Protected Attributes inherited from Monolog\Handler\AbstractHandler
 $level = Logger::DEBUG
 
 $bubble = true
 
 $formatter
 
 $processors = array()
 

Private Attributes

 $hasRecords = false
 

Detailed Description

Sends errors to Rollbar.

If the context data contains a payload key, that is used as an array of payload options to RollbarNotifier's report_message/report_exception methods.

Author
Paul Statezny pauls.nosp@m.tate.nosp@m.zny@g.nosp@m.mail.nosp@m..com

Definition at line 26 of file RollbarHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\RollbarHandler::__construct ( RollbarNotifier  $rollbarNotifier,
  $level = Logger::ERROR,
  $bubble = true 
)
Parameters
RollbarNotifier$rollbarNotifierRollbarNotifier object constructed with valid token
int$levelThe minimum logging level at which this handler will be triggered
bool$bubbleWhether the messages that are handled can bubble up the stack or not

Definition at line 47 of file RollbarHandler.php.

References Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\RollbarHandler\$rollbarNotifier.

Member Function Documentation

◆ close()

Monolog\Handler\RollbarHandler::close ( )

{Closes the handler.This will be called automatically when the object is destroyed}

Reimplemented from Monolog\Handler\AbstractHandler.

Definition at line 99 of file RollbarHandler.php.

100 {
101 if ($this->hasRecords) {
102 $this->rollbarNotifier->flush();
103 $this->hasRecords = false;
104 }
105 }

◆ write()

Monolog\Handler\RollbarHandler::write ( array  $record)
protected

{Writes the record down to the log of the implementing handler.

Parameters
array$record
Returns
void
}

Reimplemented from Monolog\Handler\AbstractProcessingHandler.

Definition at line 57 of file RollbarHandler.php.

58 {
59 if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
60 $context = $record['context'];
61 $exception = $context['exception'];
62 unset($context['exception']);
63
64 $payload = array();
65 if (isset($context['payload'])) {
66 $payload = $context['payload'];
67 unset($context['payload']);
68 }
69
70 $this->rollbarNotifier->report_exception($exception, $context, $payload);
71 } else {
72 $extraData = array(
73 'level' => $record['level'],
74 'channel' => $record['channel'],
75 'datetime' => $record['datetime']->format('U'),
76 );
77
78 $context = $record['context'];
79 $payload = array();
80 if (isset($context['payload'])) {
81 $payload = $context['payload'];
82 unset($context['payload']);
83 }
84
85 $this->rollbarNotifier->report_message(
86 $record['message'],
87 $record['level_name'],
88 array_merge($record['context'], $record['extra'], $extraData),
89 $payload
90 );
91 }
92
93 $this->hasRecords = true;
94 }

Field Documentation

◆ $hasRecords

Monolog\Handler\RollbarHandler::$hasRecords = false
private

Definition at line 40 of file RollbarHandler.php.

◆ $rollbarNotifier

Monolog\Handler\RollbarHandler::$rollbarNotifier
protected

Definition at line 33 of file RollbarHandler.php.

Referenced by Monolog\Handler\RollbarHandler\__construct().


The documentation for this class was generated from the following file: