diff --git a/logs_http.admin.inc b/logs_http.admin.inc index 1f020c2..fe32565 100644 --- a/logs_http.admin.inc +++ b/logs_http.admin.inc @@ -16,6 +16,13 @@ function logs_http_admin_settings($form, &$form_state) { '#default_value' => variable_get('logs_http_enabled', TRUE), ); + $form['logs_http_debugging_mode'] = array( + '#type' => 'checkbox', + '#title' => t('Debugging mode'), + '#description' => t('If selected, each log entry will contain a lot more details about the current http request.'), + '#default_value' => variable_get('logs_http_debugging_mode', FALSE), + ); + $form['logs_http_url'] = array( '#type' => 'textfield', '#title' => t('Endpoint'), diff --git a/logs_http.module b/logs_http.module index 1f0cf79..2845db5 100644 --- a/logs_http.module +++ b/logs_http.module @@ -152,6 +152,15 @@ function logs_http_register_event(array $log_entry) { // Remove empty values, to prevent errors in the indexing of the JSON. $event = logs_http_array_remove_empty($event); + // Avoid infinite loops when drupal_alter should ever issue new events. + static $alter_active; + if (empty($alter_active)) { + $alter_active = TRUE; + // Allow other modules to alter the event before being registered. + drupal_alter('logs_http_event', $event); + $alter_active = FALSE; + } + // Prevent identical events. $event_clone = $event; unset($event_clone['timestamp']); @@ -159,6 +168,29 @@ function logs_http_register_event(array $log_entry) { $events[$key] = $event; } +/** + * Implements hook_logs_http_event_alter(). + */ +function logs_http_logs_http_event_alter(&$event) { + if (variable_get('logs_http_debugging_mode', FALSE)) { + $events = &drupal_static('logs_http_events', array()); + if (!isset($events['debugging'])) { + $debugging_event = $event; + foreach (array('type', 'message', 'severity', 'exception_trace') as $key) { + if (isset($debugging_event[$key])) { + unset($debugging_event[$key]); + } + } + $debugging_event['debug_details'] = array( + 'GET' => $_GET, + 'POST' => $_POST, + 'COOKIE' => $_COOKIE, + ); + $events['debugging'] = $debugging_event; + } + } +} + /** * Get the registered events from the static cache. *