Skip to content

Commit

Permalink
sentry: Add breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
ondj committed Mar 24, 2024
1 parent 87e951e commit f4d0fee
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ function initializeSentry($sentryDsn) {
$scope->setTag('request_id', $_SERVER['HTTP_X_REQUEST_ID']);
}
});

App::uses('CakeLogInterface', 'Log');
class SentryLog implements CakeLogInterface
{
const LOG_LEVEL_BREADCRUMB = [
LOG_EMERG => Sentry\Breadcrumb::LEVEL_FATAL,
LOG_ALERT => Sentry\Breadcrumb::LEVEL_FATAL,
LOG_CRIT => Sentry\Breadcrumb::LEVEL_FATAL,
LOG_ERR => Sentry\Breadcrumb::LEVEL_ERROR,
LOG_WARNING => Sentry\Breadcrumb::LEVEL_WARNING,
LOG_NOTICE => Sentry\Breadcrumb::LEVEL_WARNING,
LOG_INFO => Sentry\Breadcrumb::LEVEL_INFO,
LOG_DEBUG => Sentry\Breadcrumb::LEVEL_DEBUG,
];

public function write($type, $message)
{
Sentry\addBreadcrumb('log', $message, [], self::LOG_LEVEL_BREADCRUMB[$type]);
}
}

CakeLog::config('sentry', [
'engine' => 'SentryLog',
'types' => ['notice', 'info', 'debug', 'warning', 'error', 'critical', 'alert', 'emergency'],
]);
}

$sentryDsn = Configure::read('MISP.sentry_dsn');
Expand Down

0 comments on commit f4d0fee

Please sign in to comment.