LogItem.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Copyright (C) Alibaba Cloud Computing
  4. * All rights reserved
  5. */
  6. /**
  7. * Aliyun_Log_Models_LogItem used to present a log, it contains log time and multiple
  8. * key/value pairs to present the log contents.
  9. *
  10. * @author log service dev
  11. */
  12. class Aliyun_Log_Models_LogItem {
  13. /**
  14. * @var integer time of the log item, the default time if the now time.
  15. */
  16. private $time;
  17. /**
  18. * @var array the data of the log item, including many key/value pairs.
  19. */
  20. private $contents;
  21. /**
  22. * Aliyun_Log_Models_LogItem cnostructor
  23. *
  24. * @param array $contents
  25. * the data of the log item, including many key/value pairs.
  26. * @param integer $time
  27. * time of the log item, the default time if the now time.
  28. */
  29. public function __construct($time = null, $contents = null) {
  30. if (! $time)
  31. $time = time ();
  32. $this->time = $time;
  33. if ($contents)
  34. $this->contents = $contents;
  35. else
  36. $this->contents = array ();
  37. }
  38. /**
  39. * Get log time
  40. *
  41. * @return integer log time
  42. */
  43. public function getTime() {
  44. return $this->time;
  45. }
  46. /**
  47. * Set log time
  48. *
  49. * @param integer $time
  50. * log time
  51. */
  52. public function setTime($time) {
  53. $this->time = $time;
  54. }
  55. /**
  56. * Get log contents
  57. *
  58. * @return array log contents
  59. */
  60. public function getContents() {
  61. return $this->contents;
  62. }
  63. /**
  64. * Set log contents
  65. *
  66. * @param array $contents
  67. * log contents
  68. */
  69. public function setContents($contents) {
  70. $this->contents = $contents;
  71. }
  72. /**
  73. * Add a key/value pair as log content to the log
  74. *
  75. * @param string $key
  76. * log content key
  77. * @param string $value
  78. * log content value
  79. */
  80. public function pushBack($key, $value) {
  81. $this->contents [$key] = $value;
  82. }
  83. }