Would it be possible to add an alter hook and support for ignoring certain log entries?
For example, I want to log notices but not all notices, things like Updated entity user with ID 123.
It would be nice if we could do something like:
function mymodule_raven_log_alter(&$level, &$message, &$context) {
// Ignore Rest updates.
if ($context['channel'] === 'rest' && $message === 'Updated entity %type with ID %id.') {
$context['ignore'] = TRUE;
}
}
Then we could add something like this in Raven.php:
public function log($level, $message, array $context = []) {
if (!$this->client) {
// Sad raven.
return;
}
// New stuff here...
$this->moduleHandler->alter('raven_log', $level, $message, $context);
if (!empty($context['ignore'])) {
return;
}
if (empty($this->config->get('log_levels')[$level + 1])) {
return;
}
Comments
Comment #2
joelstein commentedHere's a patch which adds this functionality and also a
raven.api.phpfile which documents it.Comment #3
joelstein commentedOops, forgot the patch!
Comment #4
mfbI would like to add this, but I'd like to make the functionality more similar to that provided in the Drupal 7 version of the module (e.g. use 'process' rather than 'ignore') to make any site upgrades easier.
Comment #5
mfbRefactored this a bit so that the entire $data array passed to Raven client can be altered by other modules - I think this would make it more generally useful.
Comment #6
mfbAdded some tests.
Comment #8
mfbPlease try out the new hook and update this issue if you find any trouble. Thanks! :)