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 6936f20
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 = [
'emergency' => Sentry\Breadcrumb::LEVEL_FATAL,
'alert' => Sentry\Breadcrumb::LEVEL_FATAL,
'critical' => Sentry\Breadcrumb::LEVEL_FATAL,
'error' => Sentry\Breadcrumb::LEVEL_ERROR,
'warning' => Sentry\Breadcrumb::LEVEL_WARNING,
'notice' => Sentry\Breadcrumb::LEVEL_WARNING,
'info' => Sentry\Breadcrumb::LEVEL_INFO,
'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 6936f20

Please sign in to comment.