71 $records = array_filter($records,
function ($record) use (
$level) {
72 return $record[
'level'] >=
$level;
80 $record = array_reduce($records,
function ($highest, $record) {
81 if ($record[
'level'] >= $highest[
'level']) {
90 foreach ($records as
$r) {
95 $record[
'context'][
'logs'] = (string) $this->
getBatchFormatter()->formatBatch($logs);
118 if (!$this->batchFormatter) {
128 protected function write(array $record)
130 $previousUserContext =
false;
132 $options[
'level'] = $this->logLevels[$record[
'level']];
134 if (!empty($record[
'extra'][
'tags'])) {
136 unset($record[
'extra'][
'tags']);
138 if (!empty($record[
'context'][
'tags'])) {
139 $options[
'tags'] = array_merge(
$options[
'tags'], $record[
'context'][
'tags']);
140 unset($record[
'context'][
'tags']);
142 if (!empty($record[
'context'][
'logger'])) {
143 $options[
'logger'] = $record[
'context'][
'logger'];
144 unset($record[
'context'][
'logger']);
146 $options[
'logger'] = $record[
'channel'];
148 if (!empty($record[
'context'])) {
149 $options[
'extra'][
'context'] = $record[
'context'];
150 if (!empty($record[
'context'][
'user'])) {
151 $previousUserContext = $this->ravenClient->context->user;
152 $this->ravenClient->user_context($record[
'context'][
'user']);
153 unset(
$options[
'extra'][
'context'][
'user']);
156 if (!empty($record[
'extra'])) {
157 $options[
'extra'][
'extra'] = $record[
'extra'];
160 if (isset($record[
'context'][
'exception']) && $record[
'context'][
'exception'] instanceof \
Exception) {
161 $options[
'extra'][
'message'] = $record[
'formatted'];
162 $this->ravenClient->captureException($record[
'context'][
'exception'],
$options);
164 $this->ravenClient->captureMessage($record[
'formatted'], array(),
$options);
167 if ($previousUserContext !==
false) {
168 $this->ravenClient->user_context($previousUserContext);
const NOTICE
Uncommon events.
const DEBUG
Detailed debug information.
const ERROR
Runtime errors.
__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)} ...
if(!is_array($argv)) $options
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 raven-php (ht...
const INFO
Interesting events.