Created
March 14, 2016 13:54
-
-
Save andeersg/fe672c14bf85a6746599 to your computer and use it in GitHub Desktop.
Simple implementation of `hook_watchdog` to send messages to external service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hook_watchdog(array $log_entry) { | |
$severity_list = array( | |
WATCHDOG_EMERGENCY => t('Emergency'), | |
WATCHDOG_ALERT => t('Alert'), | |
WATCHDOG_CRITICAL => t('Critical'), | |
WATCHDOG_ERROR => t('Error'), | |
WATCHDOG_WARNING => t('Warning'), | |
WATCHDOG_NOTICE => t('Notice'), | |
WATCHDOG_INFO => t('Info'), | |
WATCHDOG_DEBUG => t('Debug'), | |
); | |
if (strpos($log_entry['type'], 'debug') !== FALSE) { | |
$output = array( | |
'site' => $log_entry['type'], | |
'message' => t($log_entry['message'], $log_entry['variables']), | |
'status' => $severity_list[$log_entry['severity']], | |
); | |
drupal_http_request('', array( | |
'headers' => array( | |
'Content-Type' => 'application/json', | |
'Accept' => 'application/json' | |
), | |
'method' => 'POST', | |
'data' => json_encode($output), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment