Entry.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @file
  4. * Log Entry class.
  5. */
  6. namespace Redis\Logger;
  7. /**
  8. * Class Entry
  9. *
  10. * @package Redis\Logger
  11. *
  12. * @see hook_watchdog()
  13. */
  14. class Entry {
  15. /**
  16. * @var string
  17. */
  18. public $type;
  19. /**
  20. * @var stdClass
  21. * A possibly incomplete Drupal user object.
  22. */
  23. public $user;
  24. /**
  25. * @var int
  26. */
  27. public $uid;
  28. /**
  29. * @var string
  30. */
  31. public $request_uri;
  32. /**
  33. * @var string
  34. */
  35. public $referer;
  36. /**
  37. * @var string
  38. */
  39. public $ip;
  40. /**
  41. * @var int
  42. */
  43. public $timestamp;
  44. /**
  45. * @var int
  46. * Use WATCHDOG_* constants.
  47. */
  48. public $severity;
  49. /**
  50. * @var string
  51. */
  52. public $link;
  53. /**
  54. * @var string
  55. */
  56. public $message;
  57. /**
  58. * @var string[]
  59. */
  60. public $variables;
  61. public function __construct(array $entry) {
  62. foreach ($entry as $k => $v) {
  63. if (property_exists($this, $k)) {
  64. $this->$k = $v;
  65. }
  66. }
  67. }
  68. /**
  69. * @param Settings $settings
  70. *
  71. * @return string
  72. */
  73. public function getTemplateKey(Settings $settings) {
  74. return $settings->getPrefix() . "{$this->type}:{$this->severity}:{$this->message}";
  75. }
  76. }