77 $records = array_filter($records,
function ($record) use (
$level) {
78 return $record[
'level'] >=
$level;
86 $record = array_reduce($records,
function ($highest, $record) {
87 if ($record[
'level'] > $highest[
'level']) {
96 foreach ($records as
$r) {
101 $record[
'context'][
'logs'] = (string) $this->
getBatchFormatter()->formatBatch($logs);
124 if (!$this->batchFormatter) {
134 protected function write(array $record)
136 $previousUserContext =
false;
138 $options[
'level'] = $this->logLevels[$record[
'level']];
140 if (!empty($record[
'extra'][
'tags'])) {
142 unset($record[
'extra'][
'tags']);
144 if (!empty($record[
'context'][
'tags'])) {
145 $options[
'tags'] = array_merge(
$options[
'tags'], $record[
'context'][
'tags']);
146 unset($record[
'context'][
'tags']);
148 if (!empty($record[
'context'][
'fingerprint'])) {
149 $options[
'fingerprint'] = $record[
'context'][
'fingerprint'];
150 unset($record[
'context'][
'fingerprint']);
152 if (!empty($record[
'context'][
'logger'])) {
153 $options[
'logger'] = $record[
'context'][
'logger'];
154 unset($record[
'context'][
'logger']);
156 $options[
'logger'] = $record[
'channel'];
159 foreach (array(
'extra',
'context') as
$source) {
160 if (!empty($record[$source][$key])) {
162 unset($record[$source][$key]);
166 if (!empty($record[
'context'])) {
167 $options[
'extra'][
'context'] = $record[
'context'];
168 if (!empty($record[
'context'][
'user'])) {
169 $previousUserContext = $this->ravenClient->context->user;
170 $this->ravenClient->user_context($record[
'context'][
'user']);
171 unset(
$options[
'extra'][
'context'][
'user']);
174 if (!empty($record[
'extra'])) {
175 $options[
'extra'][
'extra'] = $record[
'extra'];
178 if (!empty($this->release) && !isset(
$options[
'release'])) {
182 if (isset($record[
'context'][
'exception']) && ($record[
'context'][
'exception'] instanceof \
Exception || (PHP_VERSION_ID >= 70000 && $record[
'context'][
'exception'] instanceof \
Throwable))) {
183 $options[
'message'] = $record[
'formatted'];
184 $this->ravenClient->captureException($record[
'context'][
'exception'],
$options);
186 $this->ravenClient->captureMessage($record[
'formatted'], array(),
$options);
189 if ($previousUserContext !==
false) {
190 $this->ravenClient->user_context($previousUserContext);
219 return array(
'contexts',
'checksum',
'release',
'event_id');
228 $this->release = $value;
const NOTICE
Uncommon events.
const DEBUG
Detailed debug information.
const ERROR
Runtime errors.
getExtraParameters()
Gets extra parameters supported by Raven that can be found in "extra" and "context".
__construct(Raven_Client $ravenClient, $level=Logger::DEBUG, $bubble=true)
getDefaultBatchFormatter()
Gets the default formatter for the logs generated by handleBatch().
Base Handler class providing the Handler structure.
$logLevels
Translates Monolog log levels to Raven log levels.
setBatchFormatter(FormatterInterface $formatter)
Sets the formatter for the logs generated by handleBatch().
handleBatch(array $records)
{Handles a set of records at once.The records to handle (an array of record arrays)} ...
handle(array $record)
{Handles a record.All records may be passed to this method, and the handler should discard those that...
const WARNING
Exceptional occurrences that are not errors.
const EMERGENCY
Urgent alert.
const CRITICAL
Critical conditions.
processRecord(array $record)
Processes a record.
const ALERT
Action must be taken immediately.
getBatchFormatter()
Gets the formatter for the logs generated by handleBatch().
Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server using sentry-php (h...
const INFO
Interesting events.