redis_logger.module 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * An alternate Drupal logger using Redis.
  5. *
  6. * Storage model and logic differ from http://drupal.org/project/redis_watchdog
  7. */
  8. use Redis\Logger\Entry;
  9. use Redis\Logger\Writer;
  10. /**
  11. * Implements hook_xautoload().
  12. */
  13. function redis_logger_xautoload($api) {
  14. $api->absolute()->addPsr4('Redis\Logger\\', __DIR__ . '/lib/Redis/Logger');
  15. }
  16. /**
  17. * Implements hook_menu().
  18. */
  19. function redis_logger_menu() {
  20. $items = array();
  21. $items['admin/reports/redis/logger'] = array(
  22. 'title' => 'Recent log messages in Redis',
  23. 'description' => 'View events that have recently been logged.',
  24. 'page callback' => 'drupal_get_form',
  25. 'page arguments' => array('redis_logger_form_overview'),
  26. 'access arguments' => array('access site reports'),
  27. 'weight' => -1,
  28. 'file' => 'redis_logger.admin.inc',
  29. );
  30. $items['admin/reports/redis/logger/%'] = array(
  31. 'title' => 'Details',
  32. 'page callback' => 'redis_logger_page_event',
  33. 'page arguments' => array(4),
  34. 'access arguments' => array('access site reports'),
  35. 'file' => 'redis_logger.admin.inc',
  36. );
  37. return $items;
  38. }
  39. /**
  40. * Implements hook_watchdog().
  41. */
  42. function redis_logger_watchdog(array $log_entry) {
  43. $writer = Writer::instance();
  44. $writer->log(new Entry($log_entry));
  45. }