LogItem.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. }